Thank you (as always) Luc. Works much better.
Copy-DatastoreItem : 11/10/2021 2:41:01 PM Copy-DatastoreItem Cannot find path 'DS:\TAM_Data_collector.sjrb.ad\vmware.log' because it does not
exist.
At C:\users\jmamer\VMware_scripts\SpringCleaning\PoweredOff\VMX-left-the-building.ps1:27 char:5
+ Copy-DatastoreItem -Item "DS:\$($vm.Name)\vmware.log" -Destinatio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (System.Object[]:Object[]) [Copy-DatastoreItem], VimException
+ FullyQualifiedErrorId : Core_CopyDatastoreItem_TryValidateSourceItem_InvalidSourceItem,VMware.VimAutomation.ViCore.Cmdlets.Commands.CopyD
atastoreItem
I get this is because the script couldn't find a vmware.log file, often the case if the VM has never been powered up, but how do i get a log file of VM names where vmware.log could not be read?
When I export-csv, the output looks like:
When I run on the command line it looks like this:
Why?
Joy
PS. I'll use Excel to calculate duration.