Hyper-V Powershell CMDLET Examples

Hyper-V PowerShell cmdlets provide a way to manage and automate Hyper-V virtual machines and their associated resources. Here are some commonly used cmdlets and their explanations:

  1. Get-VM: This cmdlet retrieves information about the virtual machines on a Hyper-V host.

Example: Get-VM

  1. New-VM: This cmdlet creates a new virtual machine on a Hyper-V host.

Example: New-VM -Name “VM1” -MemoryStartupBytes 1GB -NewVHDPath “C:\VMs\VM1\Disk.vhdx” -NewVHDSizeBytes 50GB

  1. Start-VM: This cmdlet starts a virtual machine that is currently turned off.

Example: Start-VM -Name “VM1”

  1. Stop-VM: This cmdlet shuts down a virtual machine.

Example: Stop-VM -Name “VM1”

  1. Remove-VM: This cmdlet removes a virtual machine from a Hyper-V host.

Example: Remove-VM -Name “VM1”

  1. Export-VM: This cmdlet exports a virtual machine to a specified location.

Example: Export-VM -Name “VM1” -Path “C:\ExportedVMs\VM1”

  1. Import-VM: This cmdlet imports a previously exported virtual machine.

Example: Import-VM -Path “C:\ExportedVMs\VM1” -Copy -GenerateNewId

  1. Get-VMNetworkAdapter: This cmdlet retrieves information about the network adapters associated with a virtual machine.

Example: Get-VMNetworkAdapter -VMName “VM1”

  1. Set-VMNetworkAdapter: This cmdlet modifies the configuration of a network adapter associated with a virtual machine.

Example: Set-VMNetworkAdapter -VMName “VM1” -StaticMacAddress “00:15:5D:5E:6F:00”

These cmdlets provide an efficient and powerful way to manage Hyper-V virtual machines through PowerShell.

Author: tonyhughes