If you work with virtualization on Windows, sooner or later you'll find yourself automating tasks. PowerShell and Hyper-V are a perfect fit : from starting or shutting down VMs to exporting them, measuring resources, or creating virtual networks, everything can be orchestrated without opening the graphical console.
In the following lines, we'll review, with examples and best practices, how to thoroughly manage Hyper-V with PowerShell . You'll see essential commands, VM creation and configuration, export and import, bulk filtering, metrics, networking and storage, as well as useful scripts for reporting your platform's status and backup options for greater peace of mind.
What is PowerShell and why use it with Hyper‑V?
PowerShell is Microsoft's .NET-based automation and scripting framework. It combines a command interpreter with a powerful scripting language , ideal for administration on Windows, macOS, and Linux.
Its commands (cmdlets) allow you to chain actions and create reusable scripts. Microsoft provides hundreds of basic cmdlets , and with the Hyper-V module, you have everything you need to manage hosts, VMs, networking, and storage from the console.

How to open and use PowerShell on Hyper‑V hosts
If the host has a GUI, open the Start menu, search for PowerShell, and run "Run as administrator ." On Server Core or Hyper-V Server installations, type powershell at the command prompt to start a PowerShell session.
For remote access using Remote Desktop on Server Core, use sconfig (option 7), and if you need to return to the console, option 15 returns you to cmd.exe . Remember to enable RDP on the host you will be connecting to.
Remote administration without RDP is even more convenient: install the tools on your workstation with Install-WindowsFeature RSAT-Hyper-V-Tools and add -ComputerName to the cmdlets (Get-VM, Start-VM, etc.) to operate on the target host. You'll be able to manage multiple hosts without switching between remote desktops.
Essential Hyper‑V cmdlets with examples
When you can't remember a command or its syntax, consult the catalog. Get-Command lists available cmdlets, functions, and aliases, and you can filter by pattern:
Get-Command -Module Hyper-V
Get-Command *-VM
Get-Command *-VHD*
For help, examples, and parameters, Get-Help clarifies the syntax and even shows practical examples:
Get-Help Get-VM
VM Inventory and Lifecycle
To view VMs on the local or remote host, Get-VM is the first step :
Get-VM
Get-VM -ComputerName Server1
Start specific VMs or batches. You can use wildcards in the name:
Start-VM -Name 'Windows Server 2016'
Start-VM -Name 'Hyper-V*'
Shuts down properly (or force-shuts down if unresponsive). Stop-VM supports -TurnOff and -Force for extreme cases, and Save-VM hibernates the state.
Stop-VM -Name 'Windows Server 2016'
Stop-VM -Name 'Hyper-V*' -TurnOff
Stop-VM -Name 'Windows Server 2016' -Force
Save-VM -Name 'Windows Server 2016'
Get-VM -Name 'Hyper-V*' | Save-VM
For graceful shutdown from the guest OS, Invoke-VMSHutdown is ideal when integration allows:
Invoke-VMShutdown -VMName 'testvps' -Force
Checkpoints (snapshots)
Checkpoints are invaluable before making critical changes. Checkpoint-VM creates the checkpoint , and Get-VMSnapshot verifies it.
Checkpoint-VM -Name 'Windows Server 2016' -SnapshotName 'Update1'
Get-VMSnapshot -VMName 'Windows Server 2016'
To clean snapshots by pattern, chain with pipelining. `Remove-VMSnapshot` deletes what you specify :
Get-VM 'Hyper-V Server 2012' | Remove-VMSnapshot -Name 'Testing*'
Virtual disks (VHD/VHDX)
Checks file paths and health. Test-VHD confirms the existence and validity of the VHD:
Test-VHD -Path 'C:\Testing.vhd'
When you need to create or attach a VHD, combine New-VHD and Add-VMHardDiskDrive to automate creation/attachment. Fixed size is a good practice for performance-sensitive workloads.
New-VHD -Path 'D:\hyper-v\virtual hard disks\wstest.vhdx' -SizeBytes 60GB -Fixed
Add-VMHardDiskDrive -VMName 'WSTEST' -Path 'D:\hyper-v\virtual hard disks\wstest.vhdx'
Metrics and network
Enable resource metering and check consumption per VM. Enable-VMResourceMetering + Measure-VM gives you CPU, RAM, disk, and network usage.
Enable-VMResourceMetering -VMName 'Windows Server 2016'
Measure-VM -VMName 'Windows Server 2016'
To list virtual adapters, include management. Get-VMNetworkAdapter includes VMs and the host itself with -All:
Get-VMNetworkAdapter -All
Configuration version, processes and filtering
After updating the host, it upgrades the VM version if necessary. Update-VMVersion does this safely.
Update-VMVersion -Name 'TestVM'
To diagnose bottlenecks, use process cmdlets. Get-Process, Stop-Process, Start-Process, Wait-Process, and Debug-Process give you control.
Get-Process -Id 8892
Get-Process WINWORD | Format-List *
Start-Process -FilePath 'notepad.exe'
Start-Process -FilePath 'powershell' -Verb RunAs
Stop-Process -Name 'notepad'
Stop-Process -Id 5052
Where-Object filters any collection. Use it with services, cmdlets, or processes to keep only what's relevant.
Get-Service | Where-Object {$_.Status -eq 'Stopped'}
Get-Command | Where-Object {$_.Name -like '*wait*'}
Get-Process | Where-Object {$_.ProcessName -Match '^sys.*'}
Create and configure VMs with PowerShell
Creating a Generation 2 VM with a new VHDX and assigned network is a matter of a single command. `new-VM` allows you to define memory, disk, path, and switch in one step:
New-VM -Name 'WSTEST' -MemoryStartupBytes 2GB -Generation 2 \
-NewVHDPath 'D:\hyper-v\virtual hard disks\WSTEST.vhdx' \
-NewVHDSizeBytes 60GB -SwitchName 'ExternalSwitch'
If you need a virtual DVD to boot from ISO, add a controller and drive. Remember to match the controller number and location to your layout.
Add-VMSCSIController -VMName 'WSTEST'
Add-VMDvdDrive -VMName 'WSTEST' -ControllerNumber 1 -ControllerLocation 0 -Path 'D:\ISO\my.iso'
You can also prepare fixed disks and attach them. Fixed VHDXs reduce fragmentation and latency in demanding I/O environments.
New-VHD -Path 'D:\hyper-v\virtual hard disks\wstest.vhdx' -SizeBytes 60GB -Fixed
Add-VMHardDiskDrive -VMName 'WSTEST' -Path 'D:\hyper-v\virtual hard disks\wstest.vhdx'
For scenarios with an existing VHD, specify -VHDPath and, if using remote administration, add -ComputerName . The -BootDevice property allows you to choose between VHD, ISO, or network boot.
New-VM -ComputerName 'Server1' -Name 'VM1' -MemoryStartupBytes 4GB \
-BootDevice VHD -VHDPath '.\VMs\Win10.vhdx' -Path '.\VMData' \
-Generation 2 -SwitchName 'ExternalSwitch'
An example of using "splatting" in PowerShell ISE to make it clean and repeatable. It's ideal for authoring templates:
$VMName = 'VMNAME'
$VM = @{
Name = $VMName
MemoryStartupBytes = 2147483648
Generation = 2
NewVHDPath = "C:\\Virtual Machines\\$VMName\\$VMName.vhdx"
NewVHDSizeBytes = 53687091200
BootDevice = 'VHD'
Path = "C:\\Virtual Machines\\$VMName"
SwitchName = (Get-VMSwitch).Name
}
New-VM @VM
Advanced administration: movements, imports and exports
To move a VM between hosts, Move-VM supports moving with or without storage, and works great when the source is on SMB:
Move-VM -ComputerName 'Server1' -Name 'VM1' -DestinationHost 'Server2'
Move-VM -ComputerName 'Server1' -Name 'VM1' -DestinationHost 'Server2' \
-IncludeStorage -DestinationStoragePath 'D:\VM_name'
Exporting creates a complete copy (configuration, VHDs, and snapshots). Export-VM is useful for archiving, testing, or ad-hoc migrations.
Export-VM -ComputerName 'Server1' -Name 'VM1' -Path 'D:\'
Get-VM | Export-VM -Path 'C:\'
Import has three modes: Register in place (same files and ID), Restore (copy to a new path preserving the ID), and Copy (copy with a new ID). Choose based on ID conflicts and target:
# Registrar in situ (elimina antes la VM original con el mismo ID)
Get-VM 'DemoVM' | Remove-VM
Import-VM -Path 'C:\\Virtual Hard Disks\\Exported VMs\\DemoVM\\Virtual Machines\\{GUID}.vmcx'
# Restaurar a nuevas rutas, conservando ID
Import-VM -Path 'C:\\Virtual Hard Disks\\Exported VMs\\Hyper-V Server 2012\\Virtual Machines\\{GUID}.vmcx' \
-Copy -VhdDestinationPath 'C:\\Program Files\\Imported VMs\\VHD Files' \
-VirtualMachinePath 'C:\\Program Files\\Imported VMs\\VM Files'
# Copiar con nuevo ID (importable varias veces en el mismo host)
Import-VM -Path 'C:\\Virtual Hard Disks\\Exported VMs\\DemoVM\\Virtual Machines\\{GUID}.vmcx' \
-Copy -GenerateNewId
If you work with Azure Local (Windows Server 2019/2022 and versions like 2311.2 onwards), remote administration with -ComputerName is the norm: inventory, start/stop, checkpoints, import/export and moves are all executed from your administration computer.
Network, storage and resources: memory and CPU
Create switches to isolate or connect VMs to the LAN. New-VMSwitch supports bandwidth modes and QoS:
New-VMSwitch 'QoS Switch' -NetAdapterName 'Wired Ethernet Connection 3' -MinimumBandwidthMode Weight
Add virtual NICs to VMs and connect them to the corresponding switch. Add-VMNetworkAdapter is your ally for VM networking.
Add-VMNetworkAdapter -ComputerName 'Server1' -VMName 'VM1' -Name 'Redmond NIC1'
Add-VMNetworkAdapter -ComputerName 'Server1' -VMName 'VM1' -SwitchName 'Network'
Dynamic memory optimizes density without losing control. Set-VMMemory adjusts minimums, start, maximums, priority, and buffer:
Set-VMMemory -ComputerName 'Server1' -Name 'VM1' -DynamicMemoryEnabled $true \
-MinimumBytes 64MB -StartupBytes 256MB -MaximumBytes 2GB -Priority 80 -Buffer 25
Assign vCPUs with limits and reservations. Set-VMProcessor defines count, reservation, maximum, and relative weight per VM:
Set-VMProcessor -ComputerName 'Server1' -Name 'VM1' -Count 2 -Reserve 10 -Maximum 75 -RelativeWeight 200
To create new disks, New-VHD covers dynamic or static VHD/VHDX scenarios. Combine it with Add-VMHardDiskDrive to attach them to the desired VM.
Bulk operations and filtering
Viewing Hyper-V module commands on an interactive grid is very useful. Out-GridView helps you inspect available commands and parameters:
Get-Command -Module Hyper-V | Out-GridView
For inventories, filter by status. Where-Object lets you see running or shut-down VMs at a glance:
Get-VM | Where-Object {$_.State -eq 'Running'}
Get-VM | Where-Object {$_.State -eq 'Off'}
Start all powered-off VMs or stop running VMs using pipelines. Ideal for scheduled tasks.
Get-VM | Where-Object {$_.State -eq 'Off'} | Start-VM
Get-VM | Where-Object {$_.State -eq 'Running'} | Stop-VM
Renaming and cleaning are also straightforward. Rename-VM and Remove-VM help you with relabeling and removal (remember, Remove-VM does not delete VHDs):
Rename-VM -ComputerName 'Server1' -Name 'VM1' -NewName 'VM2'
Get-VM -Name 'VM2'
Remove-VM -Name 'VM2'
In a cluster, remove entire groups when necessary. `Remove-ClusterGroup -RemoveResources` cleans up the VM and its cluster resources.
Get-ClusterGroup
Remove-ClusterGroup -RemoveResources -Name 'VM1'
Monitoring and Backup: Scripts and Tools
To audit the health of Hyper-V using HTML reports, Serhat Akinci's script generates a comprehensive environment report that can be emailed. Download it and see a sample output:
If you use Hyper-V Replica, the Sangeeth script monitors the replication status on single nodes or clusters and delivers a distribution-ready HTML report:
Download Replication Health Mailer
Regarding data protection, there are solutions designed for VMs such as NAKIVO Backup & Replication (VMware, Hyper-V, Nutanix, AWS EC2, Linux, Windows, and Microsoft 365) and Vinchin Backup & Recovery (Proxmox, VMware, Hyper-V, XenServer, XCP-ng, oVirt, RHV, etc.). They offer agentless backup, instant recovery, and V2V migration , and facilitate centralized policies and scheduling to minimize risks.
Keep in mind that Export-VM and Import-VM serve as ad-hoc alternatives for archiving, testing, and simple restoration, but they are not a substitute for a comprehensive backup with deduplication, encryption, and compression . Exporting requires more manual intervention and scales less well in large environments.
You now have a practical guide to bringing Hyper-V to the console: discovering cmdlets, creating and moving VMs, measuring resources, fine-tuning network and storage, bulk filtering, and reporting health . The PowerShell ecosystem gives you speed and accuracy; combine it with good copy policies and monitoring scripts, and you'll have a robust, scalable platform.