powershell v2 リモート処理 - 暗号化されていないトラフィックを有効にする方法
-
16-09-2019 - |
質問
リモートサーバーに対して実行したいPowerShell v2スクリプトを作成しています。実行すると、次のエラーが表示されます。
リモートサーバーに接続すると、次のエラーメッセージが失敗しました。WinRMクライアントはリクエストを処理できません。暗号化されていないトラフィックは現在、クライアント構成で無効になっています。クライアントconfiguratiを変更して、リクエストをもう一度試してください。詳細については、about_ remote_troubleshootingヘルプトピックを参照してください。
オンライン ヘルプで _Remote_Troubleshooting について調べましたが、暗号化されていないトラフィックを有効にする方法は示されていませんでした。以下は、私が使用している問題の原因となっているスクリプトです。
注記:リモート マシン上ですでに Enable-PSRemoting を実行して、受信リクエストを受け入れられるようにしています。
セッションオプション変数を使用しようとしましたが、違いはないようです。
$key = "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds"
Set-ItemProperty $key ConsolePrompting True
$tvar = "password"
$password = ConvertTo-SecureString -string $tvar -asPlainText –force
$username="domain\username"
$mySessionOption = New-PSSessionOption -NoEncryption
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
invoke-command -filepath C:\scripts\RemoteScript.ps1 -sessionoption $mySessionOption -authentication digest -credential $credential -computername RemoteServer
暗号化されていないトラフィックを有効にするにはどうすればよいですか?
解決
AlwaysEncrypted は、WSMAN を介してクライアント側で定義されます。ドライブ。powershell.exe (または powershell_ise.exe) を昇格されたプロセスとして実行する必要があります。
ps> cd WSMan:\localhost\Client
ps> dir
Name Value
---- -----
NetworkDelayms 5000
URLPrefix wsman
AllowUnencrypted false
Auth
DefaultPorts
TrustedHosts
(上記のディレクトリに変更した後)次のように変更します。
ps> set-item .\allowunencrypted $true
お役に立てれば、
- オイシン
他のヒント
あなたはおそらく、クライアントとサービスの両方でAllowUnencryptedコンフィグ設定を設定する必要があります。サービスの設定は、次を使用してリモートサーバに変更する必要があります:
set-item -force WSMan:\localhost\Service\AllowUnencrypted $true
そしてまた、ダイジェスト認証を有効にすることを忘れないでください。
set-item -force WSMan:\localhost\Service\Auth\Digest $true
これは私のために働いてます:
enable-wsmancredssp –role server