Get RPC client acces, Outlook Web app and Active Sync sessions per each CAS server
This script is based on Mike Pfeiffer's
It shows how many users are currently connected to each CAS detailing each sessions per protocol (RPC, OWA and EAS)
You can get the client load distribution per server, how many users are connected in each server and know when the mail client services are ready after a maintenance reboot.
The following powershell script will grab performance counter data from each CAS server to determine the number of active EAS, OWA and RPC sessions:
~~~powershell
script output PSObject
[PSObject[]] $return = @()
adding attribute into brick
function addResultAttribute ($propertyName,$propertyValue){ $result | add-member -Type NoteProperty -name $propertyname -value $propertyValue }
Add the Exchange Server 2010 Management Shell snapin
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue
function Get-CASActiveUsers { [CmdletBinding()] param( [Parameter(Position=0, ParameterSetName="Value", Mandatory=$true)] [String[]]$ComputerName, [Parameter(Position=0, ParameterSetName="Pipeline", ValueFromPipelineByPropertyName=$true, Mandatory=$true)] [String]$Name )
process {
switch($PsCmdlet.ParameterSetName) {
"Value" {$servers = $ComputerName}
"Pipeline" {$servers = $Name}
}
$servers | %{
try {
$RPC = Get-Counter "\MSExchange RpcClientAccess\User Count" -ComputerName $_ -ErrorAction SilentlyContinue
$OWA = Get-Counter "\MSExchange OWA\Current Unique Users" -ComputerName $_ -ErrorAction SilentlyContinue
$EAS = Get-Counter "\MSExchange ActiveSync\Current Requests" -ComputerName $_ -ErrorAction SilentlyContinue
}
catch {
$RPC = ""
$OWA = ""
$EAS = ""
}
# output brick
$result = New-Object PSObject
addResultAttribute "CAS Server" $_
addResultAttribute "RPC Client Access" $RPC.CounterSamples[0].CookedValue
addResultAttribute "Outlook Web App" $OWA.CounterSamples[0].CookedValue
addResultAttribute "Active Sync" $EAS.CounterSamples[0].CookedValue
# add brick into output wall
$return += $result
}
$return | ft -AutoSize
}
}
$CAS = Get-ClientAccessServer Get-CASActiveUsers -ComputerName $CAS ~~~
You only need to save the code to a ps1 file (Get-CASActiveSessions.ps1) and run it: ~~~powershell >.\Get-CASActiveSessions.ps1 ~~~
You will get somethig like this: ~~~powershell CAS Server RPC Client Access Outlook Web App Active Sync
CAS01 1540 12 1142 CAS02 781 15 589 CAS03 775 32 616 ~~~