我正在写一个powershell v2脚本,我想运行一个远程服务器。 当我运行它,我得到的错误:
连接到远程服务器失败,并显示以下错误消息:WinRM客户端无法处理请求。 未encryption的stream量当前在客户端configuration中被禁用。 更改客户端configuration并再次尝试请求。 有关更多信息,请参阅about_Remote_Troubleshooting帮助主题。
我查看了有关_ Remote_Troubleshooting的在线帮助,但是并未指出如何启用未encryption的stream量。 以下是我正在使用的脚本导致我的问题。
注意:我已经在远程机器上运行了Enable-PSRemoting,以允许它接受传入的请求。
我试图使用会话选项variables,但似乎没有任何区别。
$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
如何启用未encryption的stream量?
New-PSSessionOption有一个-NoEncryption选项。
$PSSessionOption = New-PSSessionOption -NoEncryption
在服务器端,您需要configurationWinRM(调解远程调用的底层服务)以使用未经解密的HTTP传输。 查找“winrm quickconfig”。