Hi Team
I am using the attached script to obtain the inventory from vcenter. All works well but the output to a CSV gives the datasore value as "VMware.Vim.VirtaulMachineConfigInfoDatastroreUrlPair[]" instead of the actual Datastore name.
But when I do a write-host in the end (instead of exporting to CSV) I do find the datastore name reflecting correctly.
Can someone help me figure out what i am missing?
Thanks in advance.
Sudharson AN
The problem is that the the vm can have multiple datastores and the DatastoreUrl is an object and not a string.
Try changing:
$Report.DatastoreName = $VMview.Config.DatastoreUrl
into:
$Report.DatastoreName = [string]::Join(" ",($VMview.Config.DatastoreUrl | Select-Object -Expandproperty Name))
The problem is that the the vm can have multiple datastores and the DatastoreUrl is an object and not a string.
Try changing:
$Report.DatastoreName = $VMview.Config.DatastoreUrl
into:
$Report.DatastoreName = [string]::Join(" ",($VMview.Config.DatastoreUrl | Select-Object -Expandproperty Name))