locked
Rookie Powershell question RRS feed

  • Question

  • I am working on some Active Sync statistics, and I'm googling for Powershell commands. What do I do if I find a tip saying;

    $UserList = Get-CASMailbox -Filter hasactivesyncdevicepartnership -eq $true -and -not displayname -like "CAS_{*"} | Get-Mailbox
    $UserList
    | foreach { Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity}

    I thought I could copy these two lines into a textfile and call it something.ps1, making it a Powershell script, and then run it. But no. How do I do it? Sorry for a laim question, but I'm a total rookie.

    Thursday, October 18, 2012 9:56 AM

Answers

  • Hi

    you have some bugs in this command, below should work correctly:

    $UserList = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and displayname -notlike "CAS_{*}"} | Get-Mailbox
    $UserList | foreach { Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity}

     

    it will be better to understand you if you write what you want to get as a result of this command :)

    also if you have more than 1000 mailboxes you have to use -ResultSize Unlimited

     

    Regards

    Remigiusz

    ExchangeBlog

    • Marked as answer by Evan Liu Thursday, November 8, 2012 2:46 PM
    Thursday, October 18, 2012 11:07 AM
  • Hello,

    After you saved the script as something.ps1 file, you can follow this document to run the script:

    Scripting with the Exchange Management Shell
    http://technet.microsoft.com/en-us/library/bb123798.aspx

    Thanks,

    Evan


    Evan Liu

    TechNet Community Support

    • Marked as answer by Evan Liu Thursday, November 8, 2012 2:46 PM
    Friday, October 19, 2012 9:03 AM

All replies

  • Hi

    you have some bugs in this command, below should work correctly:

    $UserList = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and displayname -notlike "CAS_{*}"} | Get-Mailbox
    $UserList | foreach { Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity}

     

    it will be better to understand you if you write what you want to get as a result of this command :)

    also if you have more than 1000 mailboxes you have to use -ResultSize Unlimited

     

    Regards

    Remigiusz

    ExchangeBlog

    • Marked as answer by Evan Liu Thursday, November 8, 2012 2:46 PM
    Thursday, October 18, 2012 11:07 AM
  • Hi

    check this link here you can find script to get all activesync devices connected to Exchange 2010 mailboxes.

    Exchange 2010 ActiveSync Devices list

     

    Remigiusz

    ExchangeBlog

    Friday, October 19, 2012 4:39 AM
  • Hello,

    After you saved the script as something.ps1 file, you can follow this document to run the script:

    Scripting with the Exchange Management Shell
    http://technet.microsoft.com/en-us/library/bb123798.aspx

    Thanks,

    Evan


    Evan Liu

    TechNet Community Support

    • Marked as answer by Evan Liu Thursday, November 8, 2012 2:46 PM
    Friday, October 19, 2012 9:03 AM