DEV Community

Cover image for EASIEST WAY TO CREATE A VIRTUAL MACHINE USING AZURE POWERSHELL AND CONNECTING IT WITH RDP
Olalekan Oladiran
Olalekan Oladiran

Posted on

EASIEST WAY TO CREATE A VIRTUAL MACHINE USING AZURE POWERSHELL AND CONNECTING IT WITH RDP

Steps involved are:

  • Log into your Azure account
  • Click on cloud Shell sign Image description
  • A command line interface will pop up, click on create storage Image description
  • If the top left corner is not showing power shell, click on bash and select power shell Image description
  • Click confirm Image description
  • First create a resource group using this code: New-AzResourceGroup -Name 'Olamy' -Location 'Eastus' Name is the name chosen for your resource group. Image description
  • What's next after creating resource group is creating the virtual machine but to do that, we must first create admin credentials for the Vm using the following command: $cred = Get-Credential -Message "Enter a username and password for the virtual machine." Image description This will ask you for username and password
  • Create the virtual machine using this command:

$vmParams = @{
ResourceGroupName = 'Olamy'
Name = 'myVM'
Location = 'eastus'
ImageName = 'Win2016Datacenter'
PublicIpAddressName = 'tutorialPublicIp'
Credential = $cred
OpenPorts = 3389
Size = 'Standard_D2s_v3'
}
$newVM1 = New-AzVM @vmParams
Image description

  • When the virtual machine is prepared, we may examine the $newVM1 variable or use the Azure Portal to see the outcomes using the command: $newVM1 Image description
  • To get some information about the new Vm like the name of the Vm and the admin account, use this command: $newVM1.OSProfile | Select-Object -Property ComputerName, AdminUserName Image description
  • Use this command to get details about the network configuration: $newVM1 | Get-AzNetworkInterface | Select-Object -ExpandProperty IpConfigurations | Select-Object -Property Name, PrivateIpAddress Image description
  • We need to connect the Vm using remote desktop protocol(rdp) with the public ip address. Use this command to get the public ip address Image description
  • To establish a Remote Desktop connection with the virtual machine, execute the subsequent command on your local computer: mstsc.exe /v $publicIp.IpAddress Image description
  • Copy and paste the public ip address of the Vm into the computer part and press connect Image description
  • You will be asked for your credentials: username and password. Image description
  • Click okay Image description
  • Click yes
  • This will load the Vm to desktop Image description

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay