Solved

Help with Powershell Cmd

Posted on 2016-09-02
5
37 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A couple of months ago we ran into an issue that necessitated re-creating our Edge Subscriptions. However, when we attempted to execute the command: New-EdgeSubscription -filename C:\NewEdgeSub_01.xml we received an error indicating that the LDAP se…
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
This video discusses moving either the default database or any database to a new volume.
Suggested Courses

617 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