Get CAS Active User Counts (Exchange 2010)

A lot of times when troubleshooting a potential Exchange CAS server issue or performing maintenance on an Exchange 2010 client access server, you’ll find you need to identify how many active connections exist on your CAS. The script found on Technet will pull your RPC, OWA, and EAS connections, but I prefer a more complete view so I’ve added Address Book, POP, IMAP, and EWS connections to fill out the script.

One thing to note about running this script – it creates a function to be called later, so you need to save it as a .ps1 file and execute it by entering “. .\filename.ps1” at the prompt. Once the function has been added to the shell you call it by entering “Get-CASActiveUsers -ComputerName casname“.


function Get-CASActiveUsers {
    [Parameter(Position=0, ParameterSetName="Value", Mandatory=$true)]
    [Parameter(Position=0, ParameterSetName="Pipeline", ValueFromPipelineByPropertyName=$true, Mandatory=$true)]

  process {
    switch($PsCmdlet.ParameterSetName) {
      "Value" {$servers = $ComputerName}
      "Pipeline" {$servers = $Name}
    $servers | %{
      $RPC = Get-Counter "\MSExchange RpcClientAccess\User Count" -ComputerName $_
      $OWA = Get-Counter "\MSExchange OWA\Current Unique Users" -ComputerName $_
      $AS = Get-Counter “\MSExchange ActiveSync\Current Requests” -ComputerName $_
      $AB = Get-Counter "\MSExchangeAB\NSPI Connections Current" -ComputerName $_
      $IMAP =  get-counter "\MSExchangeimap4(_Total)\current connections" -ComputerName $_
      $EWS = Get-Counter "\W3SVC_W3WP(*msexchangeservicesapppool)\Active Requests" -ComputerName $_
      New-Object PSObject -Property @{
        Server = $_
         "RPC Client Access" = $RPC.CounterSamples[0].CookedValue
         "Outlook Web App" = $OWA.CounterSamples[0].CookedValue
	 "ActiveSync" = $AS.CounterSamples[0].CookedValue
	 "Address Book" = $AB.CounterSamples[0].CookedValue
	 "IMAP" = $IMAP.CounterSamples[0].CookedValue
	 "EWS" = $EWS.CounterSamples[0].CookedValue
      } | Select-Object Server,"RPC Client Access","Outlook Web App",IMAP,ActiveSync,"Address Book",EWS | FT -Auto