Get-CsActiveCalls – Get Lync Mediation server active calls with powershell



This is a simple script you can use to see which server has active calls (mediation).

This uses the Get-CsWindowsService cmdlet to get the RTCMEDSRV values. This can be useful if you need to restart a server.

If you need only one server, you can also use this command :

Get-CsWindowsService -Name RTCMEDSRV | select activitylevel

To launch the function, just write the function name followed by the computername :

Get-CsActiveCalls computer01,computer02,computer03,computer04

This will show you the active calls like in the picture.

A few modifications : powershell seems to keep all values from before, so we just clear the values after showing the object with Clear-Item.

Communication Server versions tested
Office Communication Server 2007
Microsoft Lync Server 2010 OK
Microsoft Lync Server 2013 OK

Here is the script :

function Get-CsActiveCalls {
	param (
        [parameter(Mandatory=$false)][array]$Computer = $env:computername
	$BeforeProgressPreference = $ProgressPreference

	$ProgressPreference = "SilentlyContinue"
	$DateTimeDone = (Get-Date).tostring()
	Write-Host "Calls state on " -NoNewline
	Write-Host $DateTimeDone -ForegroundColor Green
    foreach ($PC in $Computer) {
        $x = Get-CsWindowsService -Name RTCMEDSRV -ComputerName $PC | select -expandproperty activitylevel
		$obj = New-Object PSObject
        $obj | Add-Member NoteProperty "Computer" $PC #.ToString()
        $findOut = $x -match '.*Current Outbound Calls=(\d+),.*'
        if ($findOut) {
            $outbound = $matches[1]
            $obj | Add-Member NoteProperty "Outbound Calls" $outbound #.ToString()
        $findIn = $x -match '.*Current Inbound Calls=(\d+),.*'    
        if ($findIn) {
            $inbound = $matches[1]
            $obj | Add-Member NoteProperty "Inbound Calls" $inbound #.ToString()
	Clear-Item $matches
	Clear-Item $obj
	Clear-Item $x
	Write-Host "Press any key to continue ..." -ForegroundColor yellow
	$KeyDown = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Get-CsActiveCalls computer01,computer02,computer03,computer04