Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

There are a couple of "issues".

  • there is a parenthesis missing at the start of the Expression code block
  • The DatastoreUrl property points to a VirtualMachineConfigInfoDatastoreUrlPair object, which has multiple properties. If you don't select the property, the Select-Object don't know how to display the values
  • A VM can have multiple datastores. To cope with that (especially when you to do an Export-Csv or similar), join the values together into one string

Try like this

Get-Datastore | Get-VM |

select Name, @{N="datastore"; e={($_ | get-view).config.datastoreurl.Name -join ' | '}}


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

View solution in original post

Reply
0 Kudos