Solved

Help with Powershell Cmd

Posted on 2016-09-02
5
34 Views
Last Modified: 2016-09-02
Need Help with Getting an overview of all ActiveSync devices in the Exchange-organization in a Comma Separated Format.

I have been working with this but cant get the username format to run correctly

Get-Mailbox -ResultSize Unlimited | ForEach {
   #$user = $mailbox.DisplayName
   $deviceinfo.User = $mailbox.DisplayName
    Get-MobileDeviceStatistics -Mailbox:$_.Identity |
   Select-Object @{label="User" ; expression={$deviceinfo.User}},DeviceOS, lastsuccesssync
   
   
}

It just repeats the same user.

Thanks in advance
0
Comment
Question by:jyoung127
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41781741
Try this..
Get-Mailbox -ResultSize Unlimited | ForEach {
     $User = $_.DisplayName
    Get-MobileDeviceStatistics -Mailbox:$_.Identity |
    Select-Object @{label="User" ; expression={$User}},DeviceOS,lastsuccesssync   
 }

Open in new window

1
 

Author Closing Comment

by:jyoung127
ID: 41781790
awesome thank you so much  
i was so close.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41781803
Yes.. $mailbox was not defined in the current script, so that values was picked possibly from a previous code which ran on the PS console. I changes it to get values form PS pipeline to fix it..
0
 

Author Comment

by:jyoung127
ID: 41781844
Hey follow up is there a way to get this exported out to a file? csv
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41781861
Use Export-csv ..
Get-Mailbox -ResultSize Unlimited | ForEach {
     $User = $_.DisplayName
    Get-MobileDeviceStatistics -Mailbox:$_.Identity |
    Select-Object @{label="User" ; expression={$User}},DeviceOS,lastsuccesssync   
 }| Export-csv C:\temp\report.csv -nti

Open in new window

1

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
A procedure for exporting installed hotfix details of remote computers using powershell
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question