LucD
Leadership
Leadership

Since you are using the pipeline in the $tasks foreach loop to capture the results, you should make sure that nothing else is placed on the pipeline.

The Stop-VMGuest, Stop-VM and Start-VM cmdlets place objects in the pipeline.

Redirect those to Out-Null (see attached file).

PS: line breaks and indentation make a file so much easier to read (and debug)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post