VMware Cloud Community
esxi1979
Expert
Expert
Jump to solution

Get-View -ViewType for datastore

Get-View -ViewType "VirtualMachine" -Property @("Name", "Config.DatastoreUrl")| Select-Object -Property Name, @{N="DataStore";E={$_.Config.DatastoreUrl}}

Above is not giving datastore path .. any suggest what is missing ?

This works well for single vm tho

1 Solution

Accepted Solutions
mattboren
Expert
Expert
Jump to solution

Hello, esxi1979-

By "datastore path", are you looking for for the names of the datastores on which the VM resides?  If so, you can adjust that calculated property to something like:

Get-View -ViewType "VirtualMachine" -Property "Name", "Config.DatastoreUrl" | Select-Object -Property Name, @{N="DataStore";E={$_.Config.DatastoreUrl | %{$_.Name}}}

That do it?

View solution in original post

1 Reply
mattboren
Expert
Expert
Jump to solution

Hello, esxi1979-

By "datastore path", are you looking for for the names of the datastores on which the VM resides?  If so, you can adjust that calculated property to something like:

Get-View -ViewType "VirtualMachine" -Property "Name", "Config.DatastoreUrl" | Select-Object -Property Name, @{N="DataStore";E={$_.Config.DatastoreUrl | %{$_.Name}}}

That do it?