SOLVED

Cannot Export to CSV when using Select-Object

Contributor

I am having an issue with exporting results from Powershell to a CSV file. When I run the command without the select-object option I get a csv fle that has way too much info in it. But when I try and pipe the export-csv to the end of the command I get an error. I am sure there is a simple explanation but I am fairly new to Power Shell and all the searching I have done is getting me nowhere any help is greatly appreciated. The command is below....

This command returns the filtered results I am looking for in the Powershell window but I want this info exported to .csv

 

 

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "MCOMEETADV"  } | select-object Displayname,Office,State,City,UsageLocation

 

 

This result runs fine too but it exports WAY too much info in the .csv file

 

 

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "MCOMEETADV"  } | Export-Csv "C:\temp\SkypeConferenceUsers.csv"

 

 

Combining the two in the below snipit give me an error and wont run.

 

 

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "MCOMEETADV"  } | select-object Displayname,Office,State,City,UsageLocation | Export-Csv "C:\temp\SkypeConferenceUsers.csv"

 

 

 

2 Replies
best response confirmed by charlie4872 (Contributor)
Solution

I don't see any problems with it, what is the error?

Thanks for the reply@Vasil Michev Oddly enough it does work. I was battling with this all morning and it may have been a typo somewhere but it is working now. I appreciate you looking at it.