In some organisations, it can be a complex task to create a sensible and resilient Enterprise Voice configuration, and it can be difficult when working on new environment’s and seeing their configuration for the first time.
Wouldn’t it be good if you could quickly show the flow from any particular Voice Policy to Gateway in one place?
Here’s a little script I put together, it’s easy to use, just run the script and it will show all the Voice Policies, or specify a Voice Policy directly, or a User, and it will show their assigned Voice Policy, and includes PSTN Usages for SimRing/Call Forwarding if specified.
Example
Please excuse the quickly thrown together configuration, I just chucked something in my lab to use as an example.
Example 1: Specify a single Voice Policy…
1 |
.\Get-CsVoiceFlow.ps1 -VoicePolicy UnlimitedCalls |
Example 2: Specify a user to retrieve Voice Policy from…
1 |
.\Get-CsVoiceFlow.ps1 -FromUser graham@sipdomain.co.uk |
Example 3: Or just show all Voice Policies…
1 |
.\Get-CsVoiceFlow.ps1 |
Download
Get-CsVoiceFlow – Version 1.1
- Version 1.0 β First release
- Version 1.1 – Seemed like v1.0 only worked in PowerShell ISE, I had to move the Function to the top and now it’s OK. (Thanks to @greiginsydney for spotting that).
Unzip and run from a PowerShell prompt.
And obviously β This Script is provided βas isβ without warranty of any kind.
The Script
Yeah I know, I used Write-Host, I’m sorry but I couldn’t resist the lure of coloured output, just change to Write-Output if you need to send to a file for later.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
<# .SYNOPSIS Lists the associated PSTN Gateway/Trunk, Voice Route, PSTN Usage, for each Voice Policy .DESCRIPTION This PowerShell script displays all Voice Policies followed by PSTN Usages, and all Voice Routes by Priority along with Number Pattern, with each Associated Mediation to PSTN Gateway or Trunk with Protocol and Port. .PARAMETER VoicePolicy Specify the the name of the VoicePolicy to display, leave blank to show all. .PARAMETER FromUser Specify the User that has a Voice Policy to display, You cannot specify VoicePolicy and FromUser at the same time. .EXAMPLE .\Get-CsVoiceFlow.ps1 This example will show the details of all Voice Polices. .EXAMPLE .\Get-CsVoiceFlow.ps1 -VoicePolicy MyVoicePolicyName This example will show the details of the specified Voice Policy. .EXAMPLE .\Get-CsVoiceFlow.ps1 -FromUser graham.cropley@sipdomain.co.uk This example will show the details of the Voice Policy that is used by the specified user. .LINK www.lyncexch.co.uk/get-csvoiceflow-shows-voice-policy-pstn-usages-routes-and-trunks #> Param( [Parameter(Position=1)] [string]$VoicePolicy = $null, [string]$FromUser = $null ) Function Display-PSTNUsages { [CmdletBinding()] Param( [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)] [System.Object[]]$PSTNUsages ) PROCESS { Foreach ($PSTNUsage in $PSTNUsages) { Write-Host " PSTN Usage """ -NoNewline Write-Host $_ -ForegroundColor Yellow -NoNewline Write-Host """" $usage = $_ $Routes = (Get-CsVoiceRoute | Sort Priority) $Routes | Where-Object {$_.PstnUsages -contains $usage} | ForEach-Object { $Priority = "{0,4}" -f ($($_.Priority)) Write-Host " $Priority - $($_.Name) """ -NoNewline Write-Host "$($_.NumberPattern)" -ForegroundColor Cyan -NoNewline Write-Host """" $_.PstnGatewayList | ForEach { $Trunk = Get-CsTrunk ([string]$_).Replace("PstnGateway:","") $Gateway = Get-CsService -PstnGateway | Where-Object {$_.DependentServiceList -like $Trunk.Identity} $Mediation = ([string]$Trunk.MediationServer).Replace("MediationServer:","") $Protocol = "" if($Trunk.GatewaySipClientTcpPort.Length -ne 0){$Protocol = "TCP/" + $Trunk.GatewaySipClientTcpPort}else{$Protocol = "TLS/" + $Trunk.GatewaySipClientTlsPort} if ($GAteway -eq $null){ Write-Host " $Mediation => $($Trunk.PoolFqdn) ($Protocol)" } Else { Write-Host " $Mediation => $($Gateway.PoolFqdn) ($Protocol) (Trunk Name = $($Trunk.PoolFqdn))" } } } } } } if($VoicePolicy -and $FromUser) { Write-Error "You cannot specify both VoicePolicy and FromUser" exit } if($FromUser) { $VP = (Get-CsUser -Identity $FromUser).VoicePolicy if($VP -eq $null){$VoicePolicy = "Global"} } if($VoicePolicy) { $VPs = Get-CsVoicePolicy -Identity $VoicePolicy }Else { $VPs = Get-CsVoicePolicy } $VPs | ForEach { Write-Host "Voice Policy """ -NoNewLine Write-Host ($_.Identity).Replace("Tag:","") -ForegroundColor Green -NoNewline Write-Host """" $_.PSTNUsages | Display-PSTNUsages if($_.CallForwardingSimulRingUsageType -eq "CustomUsage") { Write-Host "SimRing and Foward PSTN Usages" $_.CustomCallForwardingSimulRingUsages | Display-PSTNUsages } Write-host } |
Thanks
Thanks for sharing π