Azure RM VM上的WinRM

时间:2017-01-10 18:32:00

标签: powershell azure winrm

我正在尝试连接到AzureRM VM。我已经阅读了很多关于WinRM的教程,但我仍然无法让它工作:

    Enter-PSSession -ComputerName "$($HOST).cloudapp.net" -Credential $username

当我运行它时,我收到以下错误:

  

用户名或密码不正确。有关详细信息,请参阅about_Remote_Troubleshooting帮助主题

当我添加-UseSSL参数时,我收到此错误:

  

WinRM客户端无法处理请求,因为无法解析服务器名称。有关更多信息,请参阅   about_Remote_Troubleshooting帮助主题。

我输入的凭据是正确的。所以我也试过" localhost \ $ username"我得到了一个不同的错误:

  

使用Kerberos身份验证时出现以下错误,错误代码为0x80090311:

所以我尝试使用-Authentication basic,我得到了:

  

WinRM客户端无法处理请求。当前在客户端配置中禁用了未加密的流量

但我已经检查过,未加密的流量已启用。

之前有没有人遇到过这个问题?关于下一步该尝试的任何建议?

    credentials = Get-Credential -UserName $username -Message "Enter Azure account credentials"
    $continue=$false
    Do{
$session = New-PSSession -ComputerName "$($VMName).cloudapp.net" -Credential $credentials 
if ($session -ne $null)
{
  $continue=$true
}
Write-Output "Unable to create a PowerShell session . . . sleeping and trying again in 30 seconds."
Start-Sleep -Seconds 30
      }
   Until(
$continue=$true)

编辑添加服务器上现在的设置:

   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client

Type            Name                           SourceOfValue   Value
----            ----                           -------------   -----
System.String   NetworkDelayms                                 5000
System.String   URLPrefix                                      wsman
System.String   AllowUnencrypted                               true
Container       Auth
Container       DefaultPorts
System.String   TrustedHosts

客户:

   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client

 Type            Name                           SourceOfValue   Value
 ----            ----                           -------------   -----
 System.String   NetworkDelayms                                 5000
 System.String   URLPrefix                                      wsman
 System.String   AllowUnencrypted                               true
 Container       Auth
 Container       DefaultPorts
 System.String   TrustedHosts                                   @{Value = "XX.XX.XX.XX"}

2 个答案:

答案 0 :(得分:0)

也许您可以尝试使用以下cmdlet。我在实验室测试。它对我有用。

$SecureString = Read-Host -AsSecureString 'Enter your password ' | ConvertFrom-SecureString | ConvertTo-SecureString $MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "yourusername",$SecureString Enter-PSSession -ComputerName "yourcomputername" -Credential $MySecureCreds

我找到了类似的question,也许你可以查一下。

更新

WinRM服务器上,请尝试执行以下cmdlet。

winrm quickconfig

您将收到以下消息。

  

WinRM服务已在此计算机上运行。 WinRM已经设置好了   在这台电脑上进行远程管理。

客户端PC 上,请尝试使用管理员帐户执行以下cmdlet。

winrm set winrm/config/client '@{TrustedHosts = "server IP"}'

答案 1 :(得分:0)

以下参数有助于通过WINRM连接Azure VM

    $hostName="DomainName" 
$winrmPort = "5986"
# Get the credentials of the machine
$cred = Get-Credential
# Connect to the machine
$soptions = New-PSSessionOption -SkipCACheck
Enter-PSSession -ComputerName $hostName -Port $winrmPort -Credential $cred -SessionOption $soptions -UseSSL
相关问题