I use the Get-InventoryPlus function like below and it used to work....
Get-InventoryPlus | where {$_.Type -eq 'VirtualMachine'} |
ForEach-Object -Process {
Add-Member -InputObject $_ -MemberType NoteProperty -Name Datastore -Value ((Get-Datastore -VM $_.Name).Name -join '|')
Add-Member -InputObject $_ -MemberType NoteProperty -Name Network -Value ((Get-VirtualPortGroup -VM $_.Name).Name -join '|') -PassThru
} |
Export-Csv C:\Temp\Test.txt
Now I get this....
Cannot convert the "System.Object[]" value of type "System.Object[]" to type "VMware.Vim.ManagedEntity".
At C:\Temp\GetInventoryPlus-FolderPathDatastorePortgroup.ps1:125 char:11
+ $Object = Get-View -Id $Parent -Property Name,Parent
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : ConvertToFinalInvalidCastException
Any ideas?
Thanks