Skip to content

Commit 1d1ea07

Browse files
authored
Update automatic-vm-guest-patching.md - PowerShell command error
Update automatic-vm-guest-patching.md - PowerShell command for enabling/updating VM is wrong, using "Get-AzVM" you get the VM Object in the $VirtualMachine variable, after that you can perform any PowerShell commands with the "-VM $VirtualMachine" parameter, like the Set-AzVM* or the Update-AzVM*.
1 parent 7abac4d commit 1d1ea07

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

articles/virtual-machines/automatic-vm-guest-patching.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName
239239
Use the [Set-AzVMOperatingSystem](/powershell/module/az.compute/set-azvmoperatingsystem) and [Update-AzVM](/powershell/module/az.compute/update-azvm) cmdlet to enable automatic VM guest patching on an existing VM.
240240

241241
```azurepowershell-interactive
242-
$VirtualMachineName='myVM'
243-
$ResourceGroupName='myResourceGroup'
244-
$VirtualMachine=Get-AzVM -ResourceGroupName $ResourceGroupName -Name $VirtualMachineName
242+
$VirtualMachine = Get-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM"
245243
Set-AzVMOperatingSystem -VM $VirtualMachine -PatchMode "AutomaticByPlatform"
246244
Update-AzVM -VM $VirtualMachine
247245
```
@@ -297,9 +295,7 @@ GET on `/subscriptions/subscription_id/resourceGroups/myResourceGroup/providers/
297295
Use the [Get-AzVM](/powershell/module/az.compute/get-azvm) cmdlet with the `-Status` parameter to access the instance view for your VM.
298296

299297
```azurepowershell-interactive
300-
$VirtualMachineName='myVM'
301-
$ResourceGroupName='myResourceGroup'
302-
Get-AzVM -ResourceGroupName $ResourceGroupName -Name $VirtualMachineName -Status -OutVariable VirtualMachine
298+
Get-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM" -Status
303299
```
304300

305301
PowerShell currently only provides information on the patch extension. Information about `patchStatus` will also be available soon through PowerShell.

0 commit comments

Comments
 (0)