# How to change the size of the Azure VM using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

First, to retrieve the size of the Azure VM that is currently applied, we can use the below command.

PS C:\> $vm = Get-AzVM -VMName VMName PS C:\>$vm.HardwareProfile.VmSize

## Output

Standard_B1ms

Now to get the size of the Azure VMs available in the particular location we can use the below command.

PS C:\> Get-AzVMSize -VMName $vm.Name -ResourceGroupName$vm.ResourceGroupName

You will get all the available sizes for Azure VM.

Now we need to set the VM size. Here we will first set the size of the VM and then we will update the virtual machine to take the updated size.

PS C:\> $vm.HardwareProfile.VmSize = 'Standard_B2ms' PS C:\> Update-AzVM -VM$vm -ResourceGroupName \$vm.ResourceGroupName -
Verbose

We are changing the size of the VM from the Standard_B1ms to Standard_B2ms.

## Output

VERBOSE: Performing the operation "Update" on target "Win2k16VM1".
RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True                OK          OK

Once we check the hardware size, it should be updated.

PS C:\> (Get-AzVM -VMName vmname).HardwareProfile.VmSize
Standard_B2ms
Updated on 02-Sep-2021 11:08:35