Hello,
Recently, I was writing a script to delete snapshots on a VM and I'm not getting a return from Remove-Snapshots sometimes.
At times, it works fine, other times, I just never get a return and my script hangs even when the job is completed on vCenter. The snapshots didn't take a particularly long time to complete.
I'm just running:
Remove-Snapshot -Snapshot $snapshot -Confirm:$false
I'm aware that there's a -RunAsync, but there's nothing I intend on doing other than continuing to wait for the Remove-Snapshot operation to finish.
Has anyone run into this issue? I'd prefer to keep it synchronous, but if not, should I just RunAsync and then just check to see if it's completed, or does RunAsync always perform its callback?
PowerCLI: 5.1.0.4977
vSphere Client: 5.1.0 Build 941893
vCenter Server: 5.1.0 Build 1123961
Regards
I know it is a standard answer, but did you already try with a more recent PowerCLI version ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, this is the latest version that I have located in my company's Approved Software. I've just switched over to the -RunAsync due to time constraints. As much as I dislike starting an asynchronous task, just going back to a synchronous wait for it to finish..
$remTask = Remove-Snapshot -Snapshot $snapshot -RunAsync -Confirm:$false
Wait-Task -Task $remTask
And with the RunAsync it works ?
I suspect you might have stumbled on an "issue" here.
Perhaps someone from the PowerCLI Team cares to comment ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The -RunAsync works fine, I haven't run into a problem yet, which I just find really odd. I figure they'd perform the same, but just Remove-Snapshot without the -RunAsync will sometimes just cause the script to hang.
i Had the same problem using the PowerShell ISE. How do you run your script?
I was also using PowerShell ISE for both of the methods.
Are you saying it does not have the issue when you do not run it from the ISE ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Have you already tried to use the prompt? I think you`ll have another output, but it'll still hang. I don't clearly remember but this is a bug without a resolution...i'll try to find the documentation about that.
We are aware of some issues with other commands in PS4.0 and the ISE specifically, I would be interested in the results when run from the PowerCLI console.
Thanks
Running PowerShell 2.0. When I get some time, I'll try to setup some more snapshots to try and reproduce the issue. I've already cleaned up the unnecessary ones.
Haven't found the post i was looking for... I had this issue a year ago and found some people with the same problem...Some upgraded the PowerShell or PowerCLI version and solved. Some other didn't. Still looking for an answer...