Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

Use a try-catch construct around the Copy-DatastoreItem.
If the file does not exist, your script will go to the catch block, where you can log the name of the VM.

The System.STring[] in a CSV indicates that the variable you are exporting contains an array of strings, not a single string.
Export-Csv can't handle that, while the default output formatter to the console can.

An easy fix could be to use the -join operator: $field -join '|'


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

View solution in original post