DEV Community

Hyacienth Ugochukwu
Hyacienth Ugochukwu

Posted on

Creating a virtual machine using PowerShell

Go to your Azure Portal dashboard and click on the Cloud Shell icon. A coding environment will pop up below your screen. Select PowerShell and proceed to create your resource group and virtual machine.

Creating a resource group in powershell just requires this command;
New-AzResourceGroup -Name "ugopowershell" -Location "East US"

Image description

Creating a virtual machine in powershell requires this command;

New-AzVm `
-ResourceGroupName "[name of your choice]" `
-Name "[virtual machine name of your choice]" `
-Location "[location of choice]" `
-VirtualNetworkName "myVnetPS" `
-SubnetName "mySubnetPS" `
-SecurityGroupName "myNSGPS" `
-PublicIpAddressName "myPublicIpPS"

Enter fullscreen mode Exit fullscreen mode

Image description

Top comments (0)