Hello, Sache-
Yes, you can export VM info (any info, really) to CSV, and then later import it. Example:
Get-VMHost myHost0,myHost1,myHost2 | Get-VM | Select Name,PowerState,NumCpu,MemoryGB | Export-Csv c:\temp\myVMInfo.csv -UseCulture -NoTypeInformation
To later, import the VM info from the CSV, you would use Import-Csv:
$arrMyVMInfo = Import-Csv c:\temp\myVMInfo.csv
This results in an array ("$arrMyVMInfo") that contains Name, PowerState, Num CPUs, and MemoryGB info for each VM that was gotten previously. (As you know, you should be able to just save the VM info directly into a variable for use in the same PowerShell session instead of the export-to-CSV and import-from-CSV exercise).
To use that imported info to reboot guests quickly and then take snapshots, you could do something like:
## restart the guest in each of the given VMs (requires VMware Tools to be running in each guest)
Restart-VMGuest ($arrMyVMInfo | %{$_.Name}) -Confirm:$false -WhatIf
## take a snapshot of each VM after Tools are running (waits up to two minutes for tools to be started)
$arrMyVMInfo | %{
if (Wait-Tools -VM $_.Name -TimeoutSeconds 120) {
New-Snapshot -VM $_.Name -Name "snapshot0" -Description "snapshot after reboot" -Memory -Quiesce -Confirm:$false -WhatIf
} ## end if
else {"Tools did not start up on VM '$($_.Name)' in given amount of time. Snapshot not taken."}
} ## end foreach-object
Note, that restarts all of the given VMs at the same time, so be mindful of the resources in use by other machines at the time. And, the code here contains two (2) -WhatIf parameters, so will only do a dry-run as written. To actually restart all of the given guests, and to take snapshots after they are back up, take off the two -WhatIf params (on Restart-VMGuest and on New-Snapshot). Also, since boot times may vary, you might wait a bit before running the second part that does the snapshots, or adjust the -TimeoutSeconds param on Wait-Tools.
That do it for you?