【问题标题】:Enable PowerShell remoting on new Azure VM在新的 Azure VM 上启用 PowerShell 远程处理
【发布时间】:2014-02-04 19:49:53
【问题描述】:

我在 Windows Azure 中创建了一个新 VM,用作主机来学习一点 Powershell Remoting。创建虚拟机后,我将 RDP'd 放到盒子上并通过以下命令启用远程处理:

 Enable-PSRemoting

我用“a”回复确认了两个提示,并且它没有错误地完成。如果我跑

  Get-PSSessionConfiguration

我可以看到已经设置了三个端点 (?)。在 Azure 门户中,我可以看到 Powershell 端口是开放的 - 5986 都作为公共和私有端口开放。

我已将机器的公共 IP 地址添加到我的 hosts 文件中,但是当我尝试以下操作时:

  Enter-PSSession -ComputerName AZURESERVERNAME

我收到一个错误:

Enter-PSSession:连接到远程服务器 AZURESERVERNAME 失败 带有以下错误消息:指定的登录会话没有 存在。它可能已经被终止。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。在行:1 字符:1 + Enter-PSSession -ComputerName AZURESERVERNAME + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (AZURESERVERNAME:String) [Enter-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

我还尝试将所有主机设置为已信任,如下所示:

  cd wsman::localhost\client
  Set-Item .\TrustedHosts *
  Restart-Service WinRM

但这似乎也没有帮助。

我还需要做些什么来让它工作吗?

谢谢

【问题讨论】:

    标签: powershell azure powershell-remoting


    【解决方案1】:

    好的,感谢了不起的Secrets of Powershell Remoting ebook。看来您必须通过 IP 地址将机器直接添加到 TrustedHosts:

    Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value '11.22.33.44'
    

    然后使用该 IP 地址在 Enter-PSSession 中指定凭据:

    Enter-PSSession -ComputerName 11.22.33.44 -Credential 11.22.33.44\username
    

    然后您应该会收到输入密码的提示,瞧! :)

    【讨论】:

      【解决方案2】:

      我已使用来自Automated-Deployment-of-SharePoint-2013-with-Windows-Azure-PowerShell 的脚本在 Azure 中成功创建了一个 SharePoint 场

      在该页面上有配置 PowerShell 以使用 Azure 的步骤

      Set-ExecutionPolicy ByPass 
      
      Enable-PSRemoting 
      
      Enable-WSManCredSSP -role client -delegatecomputer "*.cloudapp.net"  
      
      $regKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsDomain" 
      Set-ItemProperty $regKey -Name WSMan -Value "WSMAN/*.cloudapp.net"  
      
      Get-AzureSubscription -ExtendedDetails 
      

      您可能还需要这样做

      运行 GPEdit.msc 您还必须启用新凭据的委派 在您的客户端机器上使用组策略编辑器。计算机 配置 -> 管理模板 -> 系统 -> 凭据 委派,然后更改“允许委派新鲜”的状态 仅 NTLM 服务器身份验证的凭据”改为“已启用”。 默认状态会说“未配置”。

      在添加服务器部分添加以下内容。

      WSMAN/*.cloudapp.net

      【讨论】:

      • 谢谢。遵循这些步骤但得到相同: Enter-PSSession:连接到远程服务器 AZURESERVERNAME 失败,并显示以下错误消息:指定的登录会话不存在。它可能已经被终止。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。在 line:1 char:1 + Enter-PSSession -ComputerName AZURESERVERNAME + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ + CategoryInfo : InvalidArgument: (AZURESERVERNAME:String) [Enter-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-07
      • 2016-11-21
      • 1970-01-01
      • 1970-01-01
      • 2015-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多