【问题标题】:powershell v2 remoting - How do you enable unencrypted trafficpowershell v2 远程处理 - 如何启用未加密的流量
【发布时间】:2010-11-30 23:39:02
【问题描述】:

我正在编写一个我想在远程服务器上运行的 powershell v2 脚本。当我运行它时,我得到了错误:

连接远程服务器失败 带有以下错误消息: WinRM 客户端无法处理 要求。未加密的流量是 目前在客户端禁用 配置。换客户端 配置并尝试请求 再次。有关详细信息,请参阅 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

如何启用未加密的流量?

【问题讨论】:

    标签: powershell powershell-2.0


    【解决方案1】:

    AllowEncrypted 是通过 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> 设置项 .\allowunencrypted $true

    希望这会有所帮助,

    • 欧辛

    【讨论】:

    • 这里同样的问题,即使按照你说的做了,仍然抛出同样的错误。有什么想法吗?
    • @unruledboy 再看一遍 - 它真的是说“当前在 client 配置中禁用了未加密的流量”吗?
    【解决方案2】:

    您可能需要在客户端和服务中设置 AllowUnencrypted 配置设置。必须使用以下命令在远程服务器中更改服务设置:

    set-item -force WSMan:\localhost\Service\AllowUnencrypted $true
    

    别忘了也启用摘要授权:

    set-item -force WSMan:\localhost\Service\Auth\Digest $true
    

    【讨论】:

    • 为什么需要启用摘要授权?
    • 哦,我真傻!当然是为了让系统消化新的设置。
    • 我很欣赏你的 IT 幽默@x0n
    【解决方案3】:

    您可以使用以下命令在客户端允许未加密的流量(在客户端执行):

    winrm set winrm/config/client '@{AllowUnencrypted="true"}'
    

    要验证,您可以使用以下命令获取整个配置(客户端和服务):

    winrm get winrm/config
    

    请注意,每台机器都有两个配置(一个作为客户端,一个作为服务器)。要在服务器上允许未加密的流量,请在服务器上执行以下命令:

    winrm set winrm/config/service '@{AllowUnencrypted="true"}'
    

    【讨论】:

      【解决方案4】:

      这对我有用:

      enable-wsmancredssp –role server
      

      【讨论】:

        【解决方案5】:

        如果AllowUnencryptedTraffic参数在GPO下,可以通过registrar设置:

        $RegPath = 'HKLM:\Software\Policies\Microsoft\Windows\WinRM\Client'
        $RegUnencryptedTraffic = 'AllowUnencryptedTraffic'
        $RegValue = '1'
        Set-ItemProperty -Path $RegPath -Name $RegUnencryptedTraffic -Value $RegValue
        

        【讨论】:

          猜你喜欢
          • 2010-12-14
          • 2013-02-10
          • 1970-01-01
          • 1970-01-01
          • 2010-10-12
          • 2021-07-05
          • 1970-01-01
          • 2014-09-19
          • 1970-01-01
          相关资源
          最近更新 更多