This article provides commands to take VM snapshots using PowerCLI commands.
VMware vSphere ESXi
Connect to the vCenter Server
PS C:\> Connect-VIServer -Server vCenter-FQDN
Name Port User
---- ---- ----vCenter-FQDN 443 VSPHERE.LOCAL\Administrator
1. Take snapshot of VM with memory :
Example:
PS C:\> Get-VM -Name "VM name" | New-Snapshot -Name "Test-1" -Description "test-snap" -Memory
Name Description PowerState
---- ----------- ----------
Test-1 test-snap PoweredOn
2. Take snapshot of VM with quiesce :
Example:
PS C:\> Get-VM -Name "VM name" | New-Snapshot -Name "Test-2" -Description "test-snap" -Quiesce
Name Description PowerState
---- ----------- ----------
Test-2 test-snap PoweredOff
3. Take snapshot without memory/quiesce :
Example:
PS C:\> Get-VM -Name "VM name" | New-Snapshot -Name "Test-3" -Description "test-snap"
Name Description PowerState
---- ----------- ----------
Test-3 test-snap PoweredOff
To take multiple VM snapshots, you can specify multiple VM names separated by commas.
Example:
Get-VM -Name "VM name1","VM name2" | New-Snapshot -Name "Test-4" -Description "test-snap"