Hyper-V PowerShell Commands

If you are running Hyper-V virtual machine you might find this post interesting. There is plenty of PowerShell Cmdlets for managing a Hyper-v environments.

Hyper-V Cmdlets

In this post I will cover some of the most simple Cmd-Lets you can use to manage your Hyper-V environments.

Get-VM: Shows a list of Virtual machines running on your server, with current state and Uptime.
Start-VM: Start a given Virtual machine from PowerShell.
Stop-VM: Shutdown or turn off a selected VM
Save-VM: Save the state of the virtual machine
Checkpoint-VM: Creates a Checkpoint for a given VM that you can restore to, if something goes wrong. 
Get-VMSnapshot: Get a list of snapshots for given VM.


Get-VM

In the example below we use Get-VM to get a list of all the Virtual machines running on this server and the current state of these machines:

Start-VM

In the example below I start the Virtual machine named "Windows 11:


Stop-VM

In the example below I stop the virtual machine named "Windows 11":


Save -VM

In the example below I Save the state of Virtual machine "Windows 11":


Checkpoint-VM

In the blow example we create a checkpoint named "Update 1" for the Virtual Machine named: Windows 11. This can be very useful for a Test Environment where you want to schedule a Checkpoint e.g. every 4 hours.


Get-VMSnapshot

Int the blow example I run the Get-VMSnapshot to see what available snapshost there is available on VM "Windows 11":

As you can see there is 2 Checkpoint for the machine named Windows 11. There is update 1 and update 2. Update 1 is a parrent snapshot for Update 2.


I hope you found this post informative and that you can see the power of PowerShell scripting for Hyper-V management. 

 



Comments

Popular posts from this blog

Use PowerShell to Discover Network Switch and port number

How to get Public IP Using PowerShell

Use ChatGPT to write PowerShell Scripts