Azure RM VM 上的 WinRM
WinRM on Azure RM VM
我正在尝试连接到 AzureRM VM。我已经阅读了很多关于 WinRM 的教程,但我仍然无法让它工作:
Enter-PSSession -ComputerName "$($HOST).cloudapp.net" -Credential $username
当我运行这个时,我得到以下错误:
The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic
当我添加 -UseSSL 参数时出现此错误:
The WinRM client cannot process the request because the server name cannot be resolved. For more information, see the
about_Remote_Troubleshooting Help topic.
我输入的凭据是正确的。所以我也尝试了 "localhost$username" 并且我得到了一个不同的错误:
The following error with errorcode 0x80090311 occurred while using Kerberos authentication:
所以我尝试使用 -Authentication basic 并得到:
The WinRM client cannot process the request. Unencrypted traffic is currently disabled in the client configuration
但我已经检查过并且启用了未加密的流量。
有人遇到过这个问题吗?关于接下来要尝试什么有什么建议吗?
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"}
或许您可以尝试使用以下 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
我找到了一个和你相似的,也许你可以检查一下。
更新:
在 WinRM 服务器 上,请尝试执行以下 cmdlet。
winrm quickconfig
您将收到以下消息。
WinRM service is already running on this machine. WinRM is already set
up for remote management on this computer.
在 客户端 PC 上,请尝试使用管理员帐户执行以下 cmdlet。
winrm set winrm/config/client '@{TrustedHosts = "server IP"}'
以下参数有助于通过 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
我正在尝试连接到 AzureRM VM。我已经阅读了很多关于 WinRM 的教程,但我仍然无法让它工作:
Enter-PSSession -ComputerName "$($HOST).cloudapp.net" -Credential $username
当我运行这个时,我得到以下错误:
The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic
当我添加 -UseSSL 参数时出现此错误:
The WinRM client cannot process the request because the server name cannot be resolved. For more information, see the about_Remote_Troubleshooting Help topic.
我输入的凭据是正确的。所以我也尝试了 "localhost$username" 并且我得到了一个不同的错误:
The following error with errorcode 0x80090311 occurred while using Kerberos authentication:
所以我尝试使用 -Authentication basic 并得到:
The WinRM client cannot process the request. Unencrypted traffic is currently disabled in the client configuration
但我已经检查过并且启用了未加密的流量。
有人遇到过这个问题吗?关于接下来要尝试什么有什么建议吗?
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"}
或许您可以尝试使用以下 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
我找到了一个和你相似的
更新:
在 WinRM 服务器 上,请尝试执行以下 cmdlet。
winrm quickconfig
您将收到以下消息。
WinRM service is already running on this machine. WinRM is already set up for remote management on this computer.
在 客户端 PC 上,请尝试使用管理员帐户执行以下 cmdlet。
winrm set winrm/config/client '@{TrustedHosts = "server IP"}'
以下参数有助于通过 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