gpt4 book ai didi

powershell - Azure RM VM 上的 WinRM

转载 作者:行者123 更新时间:2023-12-03 04:27:23 25 4
gpt4 key购买 nike

我正在尝试连接到 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 '输入您的密码' | ConvertFrom-SecureString |转换为安全字符串
$MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList“您的用户名”,$SecureString
Enter-PSSession -ComputerName "yourcomputername"-Credential $MySecureCreds

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

更新:

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

winrm 快速配置

您将收到以下消息。

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 = "服务器 IP"}'

关于powershell - Azure RM VM 上的 WinRM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41575897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com