问题描述
我正在编写一个想要在远程服务器上运行的 powershell v2 脚本.当我运行它时,我收到错误:
I'm writing a powershell v2 script that I'd like to run against a remote server. When I run it, I get the error :
连接远程服务器失败带有以下错误消息:WinRM 客户端无法处理要求.未加密的流量是当前在客户端中禁用配置.换客户端配置并尝试请求再次.有关更多信息,请参阅about_ Remote_疑难解答帮助主题.
我查看了关于 _ Remote_Troubleshooting 的在线帮助,但它没有告诉我如何启用未加密的流量.下面是我正在使用的导致我出现问题的脚本.
I looked at the online help for about _ Remote_Troubleshooting, but it didn't point me towards how to enable unecrypted traffic. Below is the script that I'm using that is causing me problems.
注意:我已经在远程机器上运行了 Enable-PSRemoting 以允许它接受传入的请求.
我曾尝试使用会话选项变量,但似乎没有任何区别.
Note: I have already run Enable-PSRemoting on the remote machine to allow it to accept incoming requests.
I have tried to use a session option variable, but it doesn't seem to make any difference.
$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
如何启用未加密的流量?
How do I enable unencrypted traffic?
推荐答案
AllowEncrypted 在客户端定义,通过 WSMAN: 驱动器.您必须将 powershell.exe(或 powershell_ise.exe)作为提升的进程运行.
AllowEncrypted is defined on the client end, via the WSMAN: drive. You must be running powershell.exe (or powershell_ise.exe) as an elevated process.
ps> cd WSMan:\localhost\Client
ps> dir
Name Value
---- -----
NetworkDelayms 5000
URLPrefix wsman
AllowUnencrypted false
Auth
DefaultPorts
TrustedHosts
你会像这样改变它(在改变到上面的目录之后):
You would change it like so (after changing to the directory above):
ps> set-item .\allowunencrypted $true
ps> set-item .\allowunencrypted $true
希望这会有所帮助,
- Oisin
这篇关于powershell v2 远程处理 - 如何启用未加密的流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!