leosis
asked on
Powercli : create multiple snapshots and waiting for each single process
Hi All
I need to create snapshot for multiple VM from txt , and wait for each snapshot to be created, before creating another one for the next server in the foreachloop.
trying with the following syntax the snapshots are created, but all together, with the following error:
$vmlist = get-content "c:\temp\vm.txt"
foreach ($vmName in $vmList) {
$snapshotDisable = Get-VM $vmName | New-Snapshot -Name "Newsnapshot"
do {
sleep 1
}
until (Get-Snapshot $snapshotDisable)
}
ERROR
Get-Snapshot : Cannot bind parameter 'VM'. Cannot convert the "Newsnapshot" value of type "VMware.VimAutomation.ViCore.Impl.V1.VM.SnapshotImpl" to type "VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine".
At line:7 char:29
+ until (Get-Snapshot $snapshotDisable)
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Snapshot], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetSnapshot
Any IDEA?
thanks in advance
ASKER
Hello
Patrick it's the same still have same error
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
What if you remove the double quotes from "Newsnapshot"?