Dear Team,
We have requirement to take snapshot of more than 200 VM's during the patching cycle. Now we are managing it manually and this requirement is coming every month.
Is it possible to take snapshot of the VM's from a CSV or TXT file. Would appreciate if you can help us to find PowerCLI script to do it.
Assuming you have a CSV with a column VMName that contains all the targetted VMs, you could do
Import-Csv -Path .\vmnames.csv |
ForEach-Object -Process {
Get-VM -Name $_.VMName | New-Snapshot -Name "Snapshot" -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Assuming you have a CSV with a column VMName that contains all the targetted VMs, you could do
Import-Csv -Path .\vmnames.csv |
ForEach-Object -Process {
Get-VM -Name $_.VMName | New-Snapshot -Name "Snapshot" -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you.. that was quick. just one clarification.
Once i executed the command, the results shows Powerstate as 'PoweredOff' (screenshot attached). any idea why this is showing 'PoweredOff' ?
Name Description PowerState
---- ----------- ----------
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Before-Patching-1... PoweredOff
Taking a snapshot does not power off a VM.
Were these VMs already powered off before the snapshot?
I would need to see the actual code you used.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The PowerState property in the object returned by New-Snapshot and Get-Snapshot shows the powerstate of the VM when the snapshot was taken.
Not the current powerstate of the VM.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you @LucD
