【发布时间】:2017-01-10 18:31:59
【问题描述】:
我正在尝试连接到 AzureRM 虚拟机。我已经阅读了很多关于 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"}
【问题讨论】:
-
好吧,用户名或密码不正确...您期望什么...
-
我已经尝试了大约 20 次,我向你保证......我输入的用户名和密码与我在 Azure 中设置 VM 时使用的用户名和密码相同
-
我玩得更多了,我输入了一些任意主机名,以查看是否有不同的错误消息(如找不到主机),当我使用第一个命令时,我仍然收到错误用户名和密码。
-
您确定您正在为 -Credentials 使用凭证对象吗?试试 -Credential (Get-Credential -UserName $Username)
-
是的,我正在使用该对象...我已经用我正在运行的内容更新了 OP。
标签: powershell azure winrm