SCRIPT: Set-GlobalVoiceRouting.ps1

Script Name: Set-GlobalVoiceRouting.ps1

Script Author: Ståle Hansen

Original Post: https://msunified.net/2011/02/18/script-to-enable-global-voice-routing/

Log:

  • v02 22.02.2011
    • Added Global DialinConferencingRegion on the Global DialPlan
    • Added if else check for the creation of the Voice Route
      • If GlobalRoute exist, modify, else create new
  • v01 18.02.2011
    • Initial Script, used at own risk
    • The script is intended for initial deployment for pilot or single site deployments with voice
    • Removes Default Normalization Rule under Global DialPlan
    • Creates four Normalization Rules for Norway under Global DialPlan
    • Creates Global Pstn Usage and removing prepopulated ones
    • Removes Existing Voice Route “Local Route”
    • Creates VoicePolicy Global with Pstn Usage Global
    • Creates Route named Global with Pstn Usage Global and adds the only PstnGateway in topology with NumberPattern “.*”
    • Creates and runs one Test Voice Routing
    • Writes the test result
####################################################################################################
# Set-GlobalVoiceRouting.ps1
#
# v02 February2011 by Ståle Hansen (https://msunified.net/)
#
####################################################################################################

$ErrorActionPreference = 'SilentlyContinue'

clear-host
[System.Console]::ForegroundColor = [System.ConsoleColor]::White
Write-Host Implementing and testing Global Voice Routing...

Remove-CsVoiceNormalizationRule -Identity "Global/Prefix All"

New-CsVoiceNormalizationRule -Parent Global -Name "NorEmergencyNumbers" -Description "Norwegian Emergency Numbers" -Pattern '^(11[0-3])$'-Translation '+47$1' | out-null
New-CsVoiceNormalizationRule -Parent Global -Name "NorFiveDigitNumbers" -Description "Norwegian Five Digit Numbers" -Pattern '^(0\d{4})$'-Translation '+47$1'| out-null
New-CsVoiceNormalizationRule -Parent Global -Name "NorEightDigitNumbers" -Description "Norwegian Eight Digit Numbers" -Pattern '^([1-9]\d{7})$'-Translation '+47$1'| out-null
New-CsVoiceNormalizationRule -Parent Global -Name "InternationalWithPrefix00" -Description "International numbers that start with 00" -Pattern '^00(\d*)$'-Translation '+$1'| out-null

Set-CsPstnUsage -Usage Global
Remove-CsVoiceRoute LocalRoute
Set-CsVoicePolicy -Name Global -PstnUsages Global
Set-CsDialPlan -Identity Global -DialinConferencingRegion Global

foreach($Services in (Get-CsPool)){
$PstnGW=$Services.services
$PstnGWcheck=$PSTNGW | ForEach-Object {$_.split(':')[0]}

if($PstnGWcheck -eq 'PstnGateway'){

$routetest= Get-CsVoiceRoute -Identity GlobalRoute

if($routetest.Identity -eq "GlobalRoute"){Set-CsVoiceRoute -Identity GlobalRoute -PstnGatewayList $PstnGW | out-null}

else{New-CsVoiceRoute -Identity GlobalRoute -PstnUsages Global -NumberPattern '.*' -Description "Global route for the entire organization" -PstnGatewayList $PstnGW | out-null}

}
}
New-CsVoiceTestConfiguration -Identity TestNorEightDigitNumbers -DialedNumber 70724598 -ExpectedTranslatedNumber +4770724598 -ExpectedUsage Global -ExpectedRoute GlobalRoute | out-null

[System.Console]::ForegroundColor = [System.ConsoleColor]::Green
Get-CsVoiceTestConfiguration -Identity TestNorEightDigitNumbers | Test-CsVoiceTestConfiguration | Select-Object Result | fl
[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray
$ErrorActionPreference = 'Continue'

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.