Connecting to an Azure Virtual Machine with PowerShell

Azure exposes a remoting endpoint by default to Windows Servers, and at some point you will need to turn to scripting to manage a servers

environments to perform automated tasks ,and some daily repeated tasks .

 

AZURE_RemotePorts

 

 

 

 

so you think if we got all the info above from Azure ,we are set right ?

sure .. go ahead try it 🙂

 

Connect VM on Azure with PS

Connect VM on Azure with PS

 

 

 

 

 

 

so..its not going so well, from the error we got we can learn we must use SSL authentication in order to create a session.

so we can use with

but we first must install the certificate for this VM ,in order to get the VM Certificate we can log in to the VM it-self and export it from the

MMC (Start->Run->certlm.msc->Personal->Certificates) and then install it on our local machine.

or

we can browse to the machine certificate and save it to a file instead ,like –

https://AzureVM.cloudapp.net:5986

we’ll get

VM_Cert_Error
VM_Cert_Error

 

 

 

 

 

 

 

 

 

 

go to the Certificate Details and Save it to File –

VM_Cert_Copy2File

 

 

 

 

 

 

 

 

 

 

 

 

 

 

VM_Cert

 

 

 

 

 

 

 

 

 

 

 

 

 

Now Import the saved certificate to the User Certificates, this should be imported to

(Start->Run->Certmgr.msc->Trusted Root Certification Authorities->Certificates)

Trusted_Roor_Cert

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now with the certificate installed locally, you can try to create a new PowerShell Remoting session:

AzureVM_Connecting_with_SSL

 

 

 

 

 

 

 

 

 

Now you should be able to Remote powershell with your Azure VM.

AzureVM_Connecting_with_SSL2

 

 

Enjoy!

(Visited 4,038 times, 1 visits today)

Leave a Reply