Skip to content

Update-VM

Azure: Updates an Azure virtual machine

param(
	[Parameter(Mandatory = $true)]
	[string]$ResourceGroupName,

	[Parameter(Mandatory = $true)]
	[string]$Name
)

try {
	Import-Module Az.Compute -ErrorAction Stop
	$vm = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $Name -ErrorAction Stop
	Update-AzVM -ResourceGroupName $ResourceGroupName -VM $vm -ErrorAction Stop
	Write-Output "Successfully updated VM '$Name' in resource group '$ResourceGroupName'."
} catch {
	Write-Error $_
	exit 1
}

The name of the resource group.

The name of the virtual machine.

An interactive directory of PowerShell scripts.