简体   繁体   English

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

[英]Unable to connect to Azure VM remotely using powershell

I have created a Azure VM using powershell. 我已经使用powershell创建了Azure VM。 This is the script I have used. 这是我使用的脚本。

$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

Now, I'm trying to communicate with this VM. 现在,我正在尝试与此虚拟机通信。 This is the command I have used to establish a 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

It is saying the username or password is not correct.Can anyone explain me what am I doing wrong.Thanks! 就是说用户名或密码不正确,谁能解释我在做什么错,谢谢!

What I would use is "domain\\admin" or "computer\\admin" also go through the steps on this thread here. 我要使用的是“ domain \\ admin”或“ computer \\ admin”,也可以在此通过该线程上的步骤。 https://github.com/Azure/azure-powershell/issues/1309 https://github.com/Azure/azure-powershell/issues/1309

You can add the rules of the VM which you want to connect on Azure portal. 您可以在Azure门户上添加要连接的VM的规则。 And then configure the WINRM in the vm. 然后在vm中配置WINRM。 Add trusted IP in your PC. 在您的PC中添加可信IP。

For more details, see Access Azure Windows VM through Powershell . 有关更多详细信息,请参见通过Powershell访问Azure Windows VM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM