Tuesday, February 7, 2012

Get-Snapshot - Are we there yet?

At my work, we are in the middle of performing datastore upgrade.  I am using storage vMotion to migrate the VMs live.  For storage vMotion to work you need to make sure CD is not attached and there are no snapshots on the VM.  On my storage vmotion script, I initially used Get-Snapshot to query the snapshots on the VM.  It took very, very long time to query the information and it was too slow for my taste.  Thankfully, snapshot info is available in API and I got the snapshot information quicker after I modified the script.

Get-member is my favorite command for any query.  It shows you additonal extensions from most values from Get-**** commands.  If you drill down in extensiondata, you will find wealth of information about the value. 

$vm = get-vm vm_name
$vm | Get-member


And finally, command below will give information if the VM I am looking at has snapshot.

$vm.extensiondata.snapshot


You can loop it using ForEach command to scan through the VMs.  It will be ALOT faster than using Get-SnapShot command.







No comments:

Post a Comment