Skip to content

Instantly share code, notes, and snippets.

@carlessanagustin
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlessanagustin/eb6387e788e23b7ca350 to your computer and use it in GitHub Desktop.
Save carlessanagustin/eb6387e788e23b7ca350 to your computer and use it in GitHub Desktop.
Working with Hyper-V & Snapshots/Checkpoints via PowerShell
# --- VM ---
## get hyper-v info
Get-VMHost -ComputerName computer_name | format-list *
#3 get VMs info
Get-VM -ComputerName computer_name
## get VM info
Get-VM -ComputerName computer_name -name vm_name
##start/stop
Stop-vm -name vm_name
Start-vm -name vm_name
## import VM
Import-VM -Path 'D:\Test\Virtual Machines\xxxxxxx-xxx.XML' –Copy -GenerateNewId
## export VM
Export-VM –Name vm_name –Path 'D:\Test\Virtual Machines\'
# --- Snapshots/Checkpoints ---
## create snapshot
Checkpoint-VM -ComputerName computer_name -VMName vm_name -SnapshotName "my first snapshot"
## list snapshots
Get-VMSnapshot -ComputerName computer_name -VMName vm_name
## restore snapshot
Restore-VMSnapshot -ComputerName computer_name -VMName vm_name -Name "my first snapshot" -Confirm:$false
## remove snapshop
Remove-VMSnapshot -ComputerName computer_name -VMName vm_name -Name *
## export snapshop
Export-VMSnapshot –Name 'Base Image' –VMName vm_name –Path 'D:\Test\Virtual Machines\'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment