Link to home
Create AccountLog in
Avatar of leosis
leosisFlag for Italy

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)
    } 

Open in new window

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

Open in new window


Any IDEA?

thanks in advance


Avatar of Patrick Bogers
Patrick Bogers
Flag of Netherlands image

What if you remove the double quotes from  "Newsnapshot"?

Avatar of leosis

ASKER

Hello 

Patrick it's the same still have same error

ASKER CERTIFIED SOLUTION
Avatar of Patrick Bogers
Patrick Bogers
Flag of Netherlands image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer