Finding Unused PSTN Usages

I’m working on a little project to remove unused policies, dial plans, etc. frorm our Lync 2013 configuration. It’s all fairly straightforward to find policies with no users assigned to them. But PSTN Usages? Not so easy.

PSTN Usages are a bit of a weird construct in the Lync/Skype for Business world. Forget that many people have difficulty conceptualizing what they even do. Of concern here is that all PSTN Usages get wrapped up into one global object.

When you run Get-CsPstnUsage, you get the terse output seen below.

PS C:\Users\flinchbot> get-cspstnusage

Identity : Global Usage : {Nashville-National, Nashville-International, Indianapolis-National, Indianapolis-International…}

You can get more detail on the defined usages if you run something like this:

PS C:\Users\flinchbot> (Get-CsPstnUsage).usage

This will give you the list of all of your defined PSTN Usages. But how can you tell if any of these are in use?

In order to find out if all of these are in use or not, I hacked together the below script. It grabs the list of usages then brute-force sees if that usage is defined in either a Voice Policy, a Voice Route, or in a Trunk Configuration. If it matches  any of these, then it is assumed that the PSTN Usage is in use. If it does not appear in any of the three, then the usage name is printed.

$PstnUsages = Get-CsPstnUsage
Foreach ($Usage in $PstnUsages.Usage)
    $vp = Get-CsVoicePolicy | ?{$_.PSTNUsages -contains $Usage}
    $vr = Get-CsVoiceRoute | ?{$_.PSTNUsages -contains $Usage}
    $tc = Get-CsTrunkConfiguration | ?{$_.PSTNUsages -contains $Usage} 
    If (!$vp -and !$vr -and !$tc) 
        write-host $usage 

For a one-liner you can use to find all voice policies that do not have a PSTN Usage defined, you can use this:

get-csvoicepolicy | ? {$_.PstnUsages.count -lt 1} | select identity,pstnusages

3 pings

  1. […] · Finding Unused PSTN Usages […]

  2. […] · Finding Unused PSTN Usages […]

  3. […] · Finding Unused PSTN Usages […]

Leave a Reply

Your email address will not be published.