Exchange Powershell:Get-Counter (List connections to OWA )

使用方法:

Get-CASActiveUsers -server server1,server2

Get-CASMailbox | Get-CASActiveUsers

 

$RPC = Get-Counter "\MSExchange RpcClientAccess\User Count" -ComputerName $_
$OWA = Get-Counter "\MSExchange OWA\Current Unique Users" -ComputerName $_

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 | %{
      $RPC = Get-Counter "\MSExchange RpcClientAccess\User Count" -ComputerName $_
      $OWA = Get-Counter "\MSExchange OWA\Current Unique Users" -ComputerName $_
      New-Object PSObject -Property @{
        Server = $_
        "RPC Client Access" = $RPC.CounterSamples[0].CookedValue
        "Outlook Web App" = $OWA.CounterSamples[0].CookedValue
      }
    }
  }
}
 

 

posted @ 2017-07-16 19:04  寻香径  阅读(545)  评论(0编辑  收藏  举报