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 ' | '}}