无法使用 powershell 远程连接到 Azure VM

Unable to connect to Azure VM remotely using powershell

我已经使用 powershell 创建了一个 Azure VM。这是我用过的脚本。

$UserName = "admin"
$Password = ConvertTo-SecureString "admin@123" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($UserName, $Password)    
New-AzureRmVm `
    -ResourceGroupName "RGN" `
    -Name "VName" `
    -ImageName "Imagename" `
    -Location "West US" `
    -VirtualNetworkName "Vnetname" `
    -SubnetName "default" `
    -Credential $psCred `
    -OpenPorts 3389

现在,我正在尝试与该虚拟机通信。这是我用来建立 connection/session.

的命令
$UserName = "admin"
$Password = ConvertTo-SecureString "admin@123" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($UserName, $Password)
$s = New-PSSession -ComputerName VName -Credential $psCred

它说用户名或密码不是 correct.Can 谁能解释一下我在做什么 wrong.Thanks!

我会使用的是 "domain\admin" 或 "computer\admin" 也通过这里线程中的步骤。 https://github.com/Azure/azure-powershell/issues/1309

您可以在 Azure 门户上添加要连接的 VM 的规则。然后在vm中配置WINRM。在您的 PC 中添加受信任的 IP。

有关详细信息,请参阅 Access Azure Windows VM through Powershell