Steps involved are:
- Log into your Azure account
- Click on cloud Shell sign
- A command line interface will pop up, click on create storage
- If the top left corner is not showing power shell, click on bash and select power shell
- Click confirm
- First create a resource group using this code:
New-AzResourceGroup -Name 'Olamy' -Location 'Eastus'
Name is the name chosen for your resource group.
- 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."
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
- 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
- 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
- Use this command to get details about the network configuration:
$newVM1 | Get-AzNetworkInterface |
Select-Object -ExpandProperty IpConfigurations |
Select-Object -Property Name, PrivateIpAddress
- 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
- To establish a Remote Desktop connection with the virtual machine, execute the subsequent command on your local computer:
mstsc.exe /v $publicIp.IpAddress
- Copy and paste the public ip address of the Vm into the computer part and press connect
- You will be asked for your credentials: username and password.
- Click okay
- Click yes
- This will load the Vm to desktop
Top comments (0)