That's because of the ForEach statement, that doesn't place any objects in the pipeline.
Try it like this
Get-Folder$folder|Get-VM|SelectName,@{N="DS Name";E={Get-Datastore-RelatedObject$_|Select-ExpandPropertyName}} |
Export-Csvtest.csv-NoTypeInfo
That's because of the ForEach statement, that doesn't place any objects in the pipeline.
Try it like this
Get-Folder$folder|Get-VM|SelectName,@{N="DS Name";E={Get-Datastore-RelatedObject$_|Select-ExpandPropertyName}} |
Export-Csvtest.csv-NoTypeInfo