Shutdown – Take Snapshot – PowerOn

This post was originally published on this site

LucD you provided in 2011 below

 

$VM = (Get-Content c:tempservers.txt)
foreach($vm in Get-VM -Name $VM){
   
Shutdown-VMguest -VM $vm -confirm:$false
   
while ($vm.ExtensionData.Runtime.PowerState -eq poweredOn){
       
Start-Sleep -Seconds 2
        $vm.ExtensionData.UpdateViewData(Runtime.PowerState)
    }

    New-Snapshot -VM $vm -name (get-date)

    Start-VM -VM $vm

 

}

 

I think above still work, but we are in 2020 , did the powecli team added any better way to handle this or this is it now as well.

 

Thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.