升高我试图使-psremoting与PSEXEC在我的服务器使用下面的命令:开始PowerShell与PSEXEC(启用-psremoting)
psexec.exe \\server cmd /c "echo . | powershell (-verb runas -argumentlist (enable-psremoting -force))"
,但它不工作。我猜我在搞乱双引号。任何帮助?
Sune :)
升高我试图使-psremoting与PSEXEC在我的服务器使用下面的命令:开始PowerShell与PSEXEC(启用-psremoting)
psexec.exe \\server cmd /c "echo . | powershell (-verb runas -argumentlist (enable-psremoting -force))"
,但它不工作。我猜我在搞乱双引号。任何帮助?
Sune :)
感谢评论所有!我发现了如何做到这一点,这就是完成代码:
$user = "youruser"
$p = Read-Host "Enter domain password for $adminuser"
cls
$expression1 = "enable-psremoting -force"
$commandBytes1 = [System.Text.Encoding]::Unicode.GetBytes($expression1)
$encodedCommand1 = [Convert]::ToBase64String($commandBytes1)
$expression2 = "Set-ExecutionPolicy remotesigned -Force”
$commandBytes2 = [System.Text.Encoding]::Unicode.GetBytes($expression2)
$encodedCommand2 = [Convert]::ToBase64String($commandBytes2)
$expression3 = "Restart-Service winrm”
$commandBytes3 = [System.Text.Encoding]::Unicode.GetBytes($expression3)
$encodedCommand3 = [Convert]::ToBase64String($commandBytes3)
foreach ($server in (get-content c:\temp\enablepsremotinglist.txt))
{
echo " "
echo "Running on $server"
echo "--------------------------------------- "
echo " "
psexec.exe \\$server -h -u no\$user -p $p cmd /c "echo . | powershell -EncodedCommand $encodedCommand1"
psexec.exe \\$server -h -u no\$user -p $p cmd /c "echo . | powershell -EncodedCommand $encodedCommand2"
psexec.exe \\$server -h -u no\$user -p $p cmd /c "echo . | powershell -EncodedCommand $encodedCommand3"
}
我希望这可以帮助别人1天:) PS:请记住,这个送你ADMINPASSWORD清晰文字..
它看起来像你试图调用PowerShell来运行提升。这也许是不可能的远程办?我能得到这个对机器工作不启用UAC(2003服务器):
$c = Get-Credential
$u = $c.UserName
$p = $c.GetNetworkCredential().Password
$path = "C:\SysinternalsSuite"
& "$path\psexec.exe" \\server -u $u -p $p powershell.exe -Command "Enable-PSRemoting -Force"
出于某种原因,虽然我不得不按下Enter键几次它的壳继续吐出输出,并最终让我回到提示。不知道这是怎么回事...
“它不工作”不起作用。 :)您需要提供有关“无效”的具体信息,包括您收到的* exact *错误消息。请记住,我们不能从这里阅读你的屏幕(或你的头脑),所以我们唯一要做的就是你在问题中告诉我们的内容。请编辑您的帖子并提供更具体的信息,以便这里的某个人可以尝试和帮助您。谢谢。 :) – 2012-01-11 20:17:34
您是否从PowerShell或cmd.exe运行psexec.exe? – 2012-01-11 20:34:06