2012-01-11 20 views
0

から上昇しました。私は私の二重引用符を台無しにしていると思います。どんな助け?は私が有効-psremotingをするPSEXECと私のサーバー上で次のコマンドをしようとしているPSEXEC(有効-psremotingを)

Sune :)

+1

「動作しません」が動作しません。 :)あなたが受け取っている* exact *エラーメッセージを含めて、 "動作しない"という意味の具体的な情報を提供する必要があります。私たちはここからあなたの画面(またはあなたの心)を読むことができないことを覚えておいてください。唯一のことは、あなたがあなたの質問で教えてくれることです。あなたの投稿を編集してより具体的な情報を提供してください。ここの誰かがあなたに手伝ってもらうことができます。ありがとう。 :) –

+0

PowerShellまたはcmd.exeからpsexec.exeを実行していますか? –

答えて

0

ありがとう!私はそれを行う方法を見つけ、これが完成したコードです:私は、これは他の誰か一日:) PSへの助けになることを願って

$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" 
} 

:これは明らかなように、あなたのadminpasswordのを送ることに注意してください。テキスト..

0

あなたが上昇を実行するためのPowerShellを起動しようとしているように見えます。何らかの理由で

$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キーを押しする必要がありましたけれども:これは、UACは(2003サーバー)を有効にすることなく、私は、これはマシンに対して仕事を得ることができました...リモートで行うことが可能ではないかもしれませんシェルが出力を吐き出し続けると、最終的に私はプロンプトに戻ります。それが何であるかわからない...

1

PSExecは必要ありません。 PowerShellの開発者Leeによってこのスクリプトを確認してください。すべてのコメントについて

http://poshcode.org/2141

+0

これはVista以降でのみ動作します。私はServer 2003を実行しています:( – Sune

関連する問題