Write-Host returns the correct value of the data store while Export-CSV does not work

Hi team

I use the attached script to get vcenter inventory. Everything works fine but the output to one gives CSV value like datasore ' VMware.Vim.VirtaulMachineConfigInfoDatastroreUrlPair [of] "instead of the actual data store name.

But when I do a write-host in the end (instead of export to CSV) I can't find the name of data reflecting properly store.

Can someone help me understand what Miss me?

Thanks in advance.

Olivier ONE

The problem is that the virtual machine can have several data warehouses and the DatastoreUrl is an object, not a string.

Try changing:

$Report.DatastoreName = $VMview.Config.DatastoreUrl

in:

$Report.DatastoreName = [string]: join ('',($VMview.Config.DatastoreUrl |) Select-Object name - Expandproperty))

Tags: VMware

Similar Questions

Maybe you are looking for