Select Page

Lync – Get-MCsPool

When you look for a simple way to get all Lync Server topology, you probably will do a Get-CsPool command. But here, you don’t see the sites and the output is not coming in a easily readable way.

The script below will let you Show all information at once.

Get-MCsPool will show you your infrastructure in an easy way :

Get-MCsPool

 

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

 

function Get-MCsPool{

	foreach ($site in Get-Cssite){ 
		Write-Host "Site : " $site.Displayname "( " -NoNewline -ForegroundColor Green
		if ($site.Description -notlike ""){
			Write-Host $site.Description")" -foregroundcolor Green
		}else{
			Write-Host "No description" -foregroundcolor DarkRed -NoNewline
			Write-Host " )" -foregroundcolor Green
		}
		$pools = $site | select -ExpandProperty pools
		foreach ($pool in $pools){
			$boolDiscovered = $false
			[array]$ServerType = ""
		
			Write-Host "Pool : " $pool -ForegroundColor Cyan -NoNewline
			$services = Get-CsPool $pool | select -ExpandProperty services #Get all services from the current pool
			
			If ($Site.ParentSite -ne $Null){ #SBA
				if ($services.count -ge 2){
					$ServerType += "Survivable Branch Appliance"
					$boolDiscovered = $true
				}else{
					$ServerType += " PSTN Gateway "
					$boolDiscovered = $true
				}
			}else{ #NO SBA
			
				$PoolComputersCount = (get-cspool $pool | select -ExpandProperty computers ).count #Get the computer numbers in a pool
	 			if ($PoolComputersCount -ge 2){ #POOL SERVERS (If there is 2 or more computers
					$findOut = $services -match '.*Registrar:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "Enterprise Edition Pool"
						$boolDiscovered = $true
					}
					$findOut = $services -match '.*PersistentChatService:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "Persistent Chat Pool"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*TrustedApplicationPool:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "Trusted Application Pool"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*EdgeServer:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "EDGE Pool"
        				$boolDiscovered = $true
					}
			
				}else{ #STANDALONE SERVERS (Only one computer)
	    			$findOut = $services -match '.*Registrar:([a-zA-Z]).*'
        			if ($findOut) {
						$Registrar = $findOut -replace "Registrar:",""
						$ServerType += "Standard Edition Pool"
						$boolDiscovered = $true
        			}
					$findOut = $services -match '.*PstnGateway:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "PSTN Gateway"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*EdgeServer:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "EDGE Server"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*MonitoringServer:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "Monitoring Server"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*ArchivingServer:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "Archiving Server"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*WacServer:([a-zA-Z]).*'  #Lync 2013
        			if ($findOut) {
						$ServerType += "Office Web Apps Server"
        				$boolDiscovered = $true
					}else{
						$findOut = $services -match '.*WacService:([a-zA-Z]).*' #Lync 2010
						if ($findOut) {
							$ServerType += "Office Web Apps Server"
        					$boolDiscovered = $true
						}
					}
					$findOut = $services -match '.*TrustedApplicationPool:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "Trusted Application Server"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*FileStore:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "File Server"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*ApplicationDatabase:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "SQL Server"
        				$boolDiscovered = $true
					}
					$findOut = $services -match '.*PersistentChatServer:([a-zA-Z]).*'
        			if ($findOut) {
						$ServerType += "Persistent Chat Server"
        				$boolDiscovered = $true
					}
				}#End pool or no pool
			
			}#end sba or no sba		
			
			if (!$boolDiscovered){ #If the variable is false, it means the service is unknown
				Write-Host " (N/A)" -ForegroundColor Gray -NoNewline
			}else{#If the variable is true, it means the service was discovered
				foreach ($type in $ServerType){
					if ($type -notlike ""){
						if (($type -like "*Edition*") -or ($type -like "Survivable*")){ #For the main pools, Write in Yellow
							Write-Host " ["$type" ]" -ForegroundColor Yellow -NoNewline
						}else{
							Write-Host " ["$type" ]" -ForegroundColor DarkCyan -NoNewline #For the normal service types, write in darkcyan
						}
					}
				}
			}
			Write-Host "" #Add a return after each line
		}#Close Pools foreach
	}#Close Site foreach
}#Close Get-MCsPool function

Change Voice Policy of Lync 2013 Response Group Workflow, Dialin, or any other service

There is two ways to change the Voice Policy with Lync 2013.

  • CmdLets
  • Active Directory (advanced)

First of all, we will se how to get the Voice Policy from an Application Endpoint (Workflow, Dialin etc…) :

Get-CsApplicationEndpoint -Identity "*WorkflowName*" | Select VoicePolicy
Get-CsApplicationEndpoint -Identity "*WorkflowName*" | FL *

So if you want to change the voice Policy of a Workflow with powershell, here is the cmdlet :

Get-CsApplicationEndpoint -Identity "*WorkflowName*" | GrantCsVoicePolicy -PolicyName "VPolicy-US-International"

Now we are going to be more “serious” by going to make changes in the Active Directory for the workflow itself.

First, depending on your environment, the RTC services folder can be found in different paths:

  • [Configuration]/Services/RTC Services/Application Contacts
  • [Domain Naming Context]/Services/Microsoft/RTC Services/Application Contacts

Once you’re in the path, search for the Active Directory Contact object that is your workflow, and modifies the attribute of msRTCSIP-UserPolicies.

It may have some entries like “0=123,1=6,7=2,…”

The “7=” is the voice Policy pointer. So to assign the correct voice Policy number to the Contact, Show the anchors of the voice policies in powershell and add it to the contact.

Powershell Voice Policy Anchor :

Get-CsVoicePolicy | select Anchor

This is working for all the policies.

Karl

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

Get-CsActiveCalls

Hi,

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
    )
 	$BeforeErrorActionPreference=$ErrorActionPreference
	$BeforeProgressPreference = $ProgressPreference

	$ErrorActionPreference="SilentlyContinue"
	$ProgressPreference = "SilentlyContinue"
	cls
	
	$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()
        }
		
		$obj
    }
	
	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")
	
	$ErrorActionPreference=$BeforeErrorActionPreference
	$ProgressPreference=$BeforeProgressPreference
}
Get-CsActiveCalls computer01,computer02,computer03,computer04

Lync Server 2010 – Beep before call

Hi all,

As per usual, this is a network issue. You can use Microsoft Network Monitor with port and IP filters to check connexions.

Normally, the issue is the following :

The client is making an outbound call, the call has 3 ways to process and will try the ways as follow :

  1. Internet (Edge) – The call ask the EDGE if someone with the following sip is connected trough him.
  2. PSTN – Your PSTN Gateway
  3. Voicemail – Your UM Exchange server

For any network reason (Switch, Router,Firewall,…), the client can reach the edge, but the edge can’t reach the client. This is causing several beeps before the call really begin.

Hope this helps!

Beeps before Lync call

Hi all,

As per usual, this is a network issue. You can use Microsoft Network Monitor with port and IP filters to check connexions.

Normally, the issue is the following :

The client is making an outbound call, the call has 3 ways to process and will try the ways as follow :

  1. Internet (Edge) – The call ask the EDGE if someone with the following sip is connected trough him.
  2. PSTN – Your PSTN Gateway
  3. Voicemail – Your UM Exchange server

For any network reason (Switch, Router,Firewall,…), the client can reach the edge, but the edge can’t reach the client. This is causing several beeps before the call really begin.

Hope this helps!