PowerShell Script To Get Exchange 2010 Active CAS Connections


Purpose of this script is to report on  particular performance monitor counters for Outlook RPC Client Access, OWA and Exchange ActiveSync on multiple servers.  This was required as during the course of the year there have been a few issues where the third party load balancer device was not really doing equitable load balancing.  In some cases 60% of the user load of 50,000 mailboxes was directed onto a single server. 

Using the script we can easily see the number of Outlook RPC connections, the number of OWA users and how many ActiveSync requests are issued per second.  These are all standard performance monitor counters, the script simply pulls them all into one place. 

Update 20-1-2015:  Added POP3 and IMAP4 connection counters to the script. 

 

Script Overview

The script will build a collection of all the Exchange 2010 CA servers in the organisation.  if you need to restrict the list to a single site the query can be easily modified.  For more PowerShell filtering examples please see this post.  

This is the line that would require editing if you wished to restrict the collection to a single AD site, or subset of servers:

$ExchangeServers = Get-ExchangeServer | Where-Object {$_.AdminDisplayVersion -match "^Version 14" -and $_.ServerRole -Match "ClientAccess" }  | Sort-Object  Name

 

Running The Script

The script has a handy dandy progress bar to show completion status:

Oooh Shiney - Look A Status Bar

And the finished results should look something like the below, except that your numbers will likely not be zero.  Mine are zero as this is a lab…

PowerShell Script Showing CAS Connections

 

Script Download

Please download the script from the TechNet Gallery:

Download PowerShell Script To Show Exchange 2010 CAS Connections

 

Please also provide feedback here or on the TechNet Gallery site!

Cheers,

Rhoderick

PS Note to self:  Script is clearly lacking as there is no magenta text………..

Comments (19)

  1. Does this script support Exchange 2013 CAS?

  2. Gerat script as usual Rhoderick, Would it be possible to add the IMAP4 counter??
    $WorkingObject.IMAP = [math]::Truncate((Get-Counter "MSExchangeImap4(_total)Current Connections" -ComputerName $Server.Name).CounterSamples[0].Cookedvalue)

  3. anonymouscommenter says:

    Hi Rhoderick, awesome script, very handy dandy indeed dude (try to say the 5 last word fast) ! Is there a way to dump the list of who is connected to the CAS ?

  4. Hi Martijn,

    it will need some editing for Exhange 2013. CAS13 has the OWA proxy component. The perf counter above exists on the MBX role in E15.

    Cheers,
    Rhoderick

  5. Thanks Feras!

    Certainly – I’ll add that. As and added bonus will do POP3 as well 🙂

    Cheers,
    Rhoderick

  6. Hi Sam,

    You can look at the RPC Client access logs to determine this.

    Should i wuire a quick n dirty script on that? Think there is demand for that?

    Cheers,
    Rhoderick

  7. Hi Feras,

    I added POP & IMAP in.

    Can you download V3 and let me know how you get on please?

    Cheers,
    Rhoderick

  8. anonymouscommenter says:

    Hello, Rhoderick

    If I want to run this script against E15 severs, as E15 is using CAS Proxy, will these counter still reflect real RPC connection per CAS server? Thanks!

    Regards,

    Jing

  9. anonymouscommenter says:

    is it possible to get list of all CAS Servers(including Exchange 2013) from shell of exchange 2010?

  10. anonymouscommenter says:

    I`m getting some results back but its also littered with errors for each CAS.

    Get-Counter : The \CAS01\MSExchangePOP3(_total)Connections Current performance counter path is not valid.
    At H:PowershellExchange 2010CAS UsersGet-Active-Cas-Connections-v3.ps1:107 char:56
    + $WorkingObject.POP = [math]::Truncate((Get-Counter <<<< "MSExchangePOP3(_total)Connections Current" -Compute
    rName $Server.Name).CounterSamples[0].Cookedvalue)
    + CategoryInfo : InvalidResult: (:) [Get-Counter], Exception
    + FullyQualifiedErrorId : CounterPathIsInvalid,Microsoft.PowerShell.Commands.GetCounterCommand

    Cannot index into a null array.
    At H:PowershellExchange 2010CAS UsersGet-Active-Cas-Connections-v3.ps1:107 char:147
    + $WorkingObject.POP = [math]::Truncate((Get-Counter "MSExchangePOP3(_total)Connections Current" -ComputerName
    $Server.Name).CounterSamples[ <<<< 0].Cookedvalue)
    + CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

  11. Pat001 says:

    I get the same errors as Rob’s reply, Running v3, Any update on solution?
    thanks
    Pat

  12. Great script. You might have more fun commenting scripts than anyone I’ve ever met

  13. Hey Daniel,

    Yes – guilty as charged, and that is a sanitised version 🙂

    Cheers,
    Rhoderick

  14. Keshava Channabyraiah says:

    Good script, thanks
    With 4 counters it can display as table with Single header. For more than 4 counters it display as a list.
    I mean if we remove POP and IMP it can display as table as required

    ServerName RPC OWA EAS
    ———- — — —
    Server1 2 0 0
    Server2 2 4 0

    With POP and IMAP it gives a a list

    ServerName :ServerName
    RPC : 0
    OWA : 0
    EAS : 0
    IMAP :
    POP :

  15. Thanks Keshava,

    Feel free to edit and modify, some customers wanted the POP & IMAP added. This is sample code and you can tweak as needed to suit your requirements.

    Great to hear you find it useful.

    Cheers,
    Rhoderick

  16. Jack H. says:

    This is great! Thank you for your work

    1. Glad you find it useful!

      Cheers,
      Rhoderick

  17. Michael Stein says:

    Hello,

    can I use this script at a German SBS 2011? Do I need to change something?

    1. Hallo!

      The script may need to be updated to reflect the language specific perf counters. I do not have Deutsch server installed Michael – but take a look in the Perfmon on your machine to see if/how the perf counters match.

      Edit as necessary

      Cheers,
      Rhoderick

Skip to main content