Delete all VM’ from the previous MOC course using PowerShell

 

# Delete ALL VMs

Before installing VM’s for a new MOC course we need to delete the VM’s from the previous course.

To delete all MOC VM’s from a previous course including all snapshots we can use GUI mode or PowerShell 3.0.

In Hyper-V console we can select all VM’s, right-click and select Delete.

In PowerShell 3.0 one line does it all.

If want to give the opportunity to accept or reject VM’s deletion we use.

Get- VM |Remove-VM

First part of the command will select all VM’s and the second part will delete VM’s waiting for user validation on what WM’s should be deleted.

If we want to delete VM’s without any user intervention we use:

Get-VMSwitch | Remove-VMSwitch -force

First part of the command will select all VM’s and the second part will delete all VM’s without any user intervention.

Note: Deleting VM’s in Hyper-V context will not delete the files associated to the VM’s as it happens in SCVMM.

To release the space occupied by files from previous course we have to delete them manually.

 

Live is too short, don’t waist it on classroom setups!

 

Florin Nicolescu

MCT

florin@learningsolution.ro

www.learningsolution.ro

www.cursurimicrosoft.com