{"id":6755,"date":"2015-07-23T20:06:10","date_gmt":"2015-07-23T20:06:10","guid":{"rendered":"http:\/\/www.highclouder.ninja\/?p=6755"},"modified":"2024-05-21T14:49:56","modified_gmt":"2024-05-21T14:49:56","slug":"determine-number-active-users-exchange-servers-powershell","status":"publish","type":"post","link":"https:\/\/www.highclouder.com\/?p=6755","title":{"rendered":"Determine the Number of Active Users on Exchange Servers with PowerShell"},"content":{"rendered":"<p>It\u2019s always good to know how many users might be affected by an taking a server down. The following PowerShell function will grab performance counter data from each server to determine the number of active OWA and RPC connections:<br \/>\n<!--more--><\/p>\n<pre class=\"lang:default decode:true \" >function Get-CASActiveUsers {\n [CmdletBinding()]\n\nparam(\n [Parameter(Position=0,\nParameterSetName=\"Value\", Mandatory=$true)]\n\n[String[]]$ComputerName,\n\n[Parameter(Position=0, ParameterSetName=\"Pipeline\",\nValueFromPipelineByPropertyName=$true,\nMandatory=$true)]\n\n[String]$Name\n )\n process {\n switch($PsCmdlet.ParameterSetName)\n{\n \"Value\" {$servers =\n$ComputerName}\n \"Pipeline\" {$servers =\n$Name}\n }\n $servers |\n%{\n $RPC = Get-Counter \"\\MSExchange\nRpcClientAccess\\User Count\" -ComputerName $_\n\n$OWA = Get-Counter \"\\MSExchange OWA\\Current Unique Users\" -ComputerName\n$_\n New-Object PSObject -Property\n@{\n Server =\n$_\n \"RPC Client Access\" =\n$RPC.CounterSamples[0].CookedValue\n\n\"Outlook Web App\" =\n$OWA.CounterSamples[0].CookedValue\n\n}\n }\n }\n}\n<\/pre>\n<p>Just add the function to your shell session and when you run it, specify one or more server names using the -ComputerName parameter:<\/p>\n<pre class=\"lang:default decode:true \" >Get-CASActiveUsers -ComputerName ex1,ex2<\/pre>\n<p>The function is also written to support pipeline input, so you can pipe the <strong>Get-ClientAccessServer<\/strong> cmdlet to it as well:<\/p>\n<pre>Get-ClientAccessServer | Get-CASActiveUsers<\/pre>\n<p>It can take a few minutes before the values are updated as clients connect or disconnect.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s always good to know how many users might be affected by an taking a server down. The following PowerShell function will grab performance counter data from each server to determine the number of active OWA and RPC connections:<\/p>\n","protected":false},"author":1,"featured_media":6731,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4,8],"class_list":["post-6755","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-exchange","tag-powershell"],"_links":{"self":[{"href":"https:\/\/www.highclouder.com\/index.php?rest_route=\/wp\/v2\/posts\/6755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.highclouder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.highclouder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.highclouder.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.highclouder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6755"}],"version-history":[{"count":1,"href":"https:\/\/www.highclouder.com\/index.php?rest_route=\/wp\/v2\/posts\/6755\/revisions"}],"predecessor-version":[{"id":7267,"href":"https:\/\/www.highclouder.com\/index.php?rest_route=\/wp\/v2\/posts\/6755\/revisions\/7267"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.highclouder.com\/index.php?rest_route=\/wp\/v2\/media\/6731"}],"wp:attachment":[{"href":"https:\/\/www.highclouder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.highclouder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.highclouder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}