Share via


exchange powershell export to csv

Question

Thursday, February 1, 2018 5:04 AM

Dear All,

We have executed the below command in exchange 2010 powershell and getting the output in the screen but unable to export in csv

foreach ($user in $device) { Get-ActiveSyncDeviceStatistics -mailbox $user | Select-object identity, devicetype, Lastsuccesssync }

Trying to export in csv with the below command but its not exported and give different values

foreach ($user in $device) { Get-ActiveSyncDeviceStatistics -mailbox $user | Select-object identity, devicetype, Lastsuccesssync | Export-csv d:\data.csv }

Exported in csv as below. Kindly advise

ClassId2e4f51ef21dd47e99d3c952918aff9cd
033ecb2bc07a4d43b5ef94ed5a35d280

Regards

Raj

All replies (5)

Thursday, February 1, 2018 8:39 AM

Try this instead:

foreach ($user in $device) { Get-ActiveSyncDeviceStatistics -mailbox $user | Select-object identity, devicetype, Lastsuccesssync } | Export-csv d:\data.csv 

Thursday, February 1, 2018 10:02 AM

Its not working and the error reported as

An empty pipe element is not allowed.

Kindly advise


Friday, February 2, 2018 6:39 AM

Hi,

If you run the scripts without exporting to CSV, could you get the correct result from the EMS?

foreach ($user in $device) { Get-ActiveSyncDeviceStatistics -mailbox $user | Select-object identity, devicetype, Lastsuccesssync | Export-csv -encoding "unicode" -Path d:\data.csv }

If issue persists, be free to post back!

Regards,

Manu Meng

Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact [email protected].

Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.


Thursday, February 8, 2018 7:25 AM

Thank you for your reply.

Sorry for the delayed response

I am able to get in csv file but the problem it provides the active sync details only for one user account

In $device file i have a list of 50 users but the output provides only for one user. I tried the below command and need to get for all the users

foreach ($user in $device) { Get-ActiveSyncDeviceStatistics -mailbox $user | Select-object identity, devicetype, Lastsuccesssync | Export-csv -encoding "unicode" -Path d:\data.csv}

Kindly advice

Thank you


Thursday, February 22, 2018 3:37 PM

The csv file should have a column name such name, alias, etc. Let's say it is alias.

Please try the following command: 

foreach ($user in $device) { Get-ActiveSyncDeviceStatistics -mailbox $user.alias | Select-object identity, devicetype, Lastsuccesssync | Export-csv -encoding "unicode" -Path d:\data.csv}

Regards,

Manu Meng

Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact [email protected].

Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.