SCVMM: Creating Checkpoints with PowerShell
It isn’t possible to create a checkpoint with SCVMM beta1 for VMs that are running. The obvious solution is to write a script to stop the VM first, then create the checkpoint and start it again. I’ve written a script that does exactly that, and it does it for all running VMs.
When I first looked at the checkpoint feature I was dissapointed that there wasn’t an option to add a description. I’ve discovered that while it’s not possible to add and view descritptions through the GUI, you are able to do it using PowerShell.
The following script stops all running VMs, creates a checkpoint with a description, then starts the VMs again.
$VMs = Get-VM -server localhost | where{$_.VMState -eq 'Running'}
$StopVMs = $VMs | Stop-VM
$CheckpointResult = $VMs | New-VMCheckPoint -description "CheckPoint created from script"
$StartVMs = $VMs | Start-VM
You won’t be able to view the description through the GUI, but you can see it if you retreive the checkpoint information via the Get-VMCheckpoint cmdlet:
Get-vmcheckpoint -server server1
Note that server1 is the SCVMM server, not a VM. The cmdlet will list all checkpoints for all VMs that are managed by SCVMM. There is a -VM option, but it doesn’t work with beta1 (along with a lot of other options) There is a way to get around this limiation however, and that is to get the VM object first and then use the Get-VMCheckPoint cmdlet. You can do this for other commands like Start-VM and Stop-VM as well. Here’s an example, including the output:
PS C:\> $VM = "wnlabap101"
PS C:\> $VMObject = Get-VM -server localhost | where{$_.Name -eq $VM}
PS C:\> $VMObject | Get-VMCheckPoint -server localhost
VM : WNLABAP101
ObjectType : VMCheckpoint
Accessibility : Public
Name :
Description :
CreationTime : 8/03/2007 10:13:35 AM
ModifiedTime : 8/03/2007 10:13:38 AM
AccessedTime : 8/03/2007 10:13:38 AM
MarkedForDeletion : False
MostRecentTask :
ServerConnection : Microsoft.VirtualManager.Monad.Remoting.ServerConnection
ID : ca85e266-e658-47d5-951a-42af29762e8d
VM : WNLABAP101
ObjectType : VMCheckpoint
Accessibility : Public
Name :
Description : CheckPoint created from script
CreationTime : 19/03/2007 4:28:53 PM
ModifiedTime : 19/03/2007 4:28:56 PM
AccessedTime : 19/03/2007 4:28:56 PM
MarkedForDeletion : False
MostRecentTask :
ServerConnection : Microsoft.VirtualManager.Monad.Remoting.ServerConnection
ID : 1533e5df-f86c-4366-bedf-56e5944a8a83
VM : WNLABAP101
ObjectType : VMCheckpoint
Accessibility : Public
Name :
Description :
CreationTime : 12/03/2007 1:25:08 PM
ModifiedTime : 12/03/2007 1:25:11 PM
AccessedTime : 12/03/2007 1:25:11 PM
MarkedForDeletion : False
MostRecentTask :
ServerConnection : Microsoft.VirtualManager.Monad.Remoting.ServerConnection
ID : 899be449-6130-41ba-bbe9-ba47ae907981