VMware Cloud Community
COS
Expert
Expert
Jump to solution

Get-InventoryPlus - include datastores friendly name

I'm using the script from LucD founde here: Get-InventoryPlus - Inventory of all vSphere objects - LucD notes

Works great with my execution below..

Get-InventoryPlus | where {$_.Type -eq 'VirtualMachine'} | Export-Csv C:\Temp\VMFolders_20190305.csv

How do I have it output also the VM's datastore friendly name?

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-InventoryPlus | where {$_.Type -eq 'VirtualMachine'} |

ForEach-Object -Process {

   Add-Member -InputObject $_ -MemberType NoteProperty -Name Datastore -Value ((Get-Datastore -VM $_.Name).Name -join '|') -PassThru

} |

Export-Csv C:\Temp\VMFolders_20190305.csv


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-InventoryPlus | where {$_.Type -eq 'VirtualMachine'} |

ForEach-Object -Process {

   Add-Member -InputObject $_ -MemberType NoteProperty -Name Datastore -Value ((Get-Datastore -VM $_.Name).Name -join '|') -PassThru

} |

Export-Csv C:\Temp\VMFolders_20190305.csv


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

Reply
0 Kudos
COS
Expert
Expert
Jump to solution

That took about a full hour but it got me the exact data I needed.

Thanks!

Reply
0 Kudos
RJ4719
Contributor
Contributor
Jump to solution

test
Reply
0 Kudos