Lync - Add PSTN usages to a Voice POLICY not route

I am posting this on behalf of my good friend. She has helped me out immensely in the past with any Lync issues that I came across. She is now delving into PowerShell which I know will make her life a whole lot easier.

Unfortunately, I no longer have access to Lync so I am posting here in hopes that someone can assist.

######################################################################

Lync Voice Routes have one component that cannot be edited by simple commands in PowerShell.

What I am referring to are PSTNUsages.

If you go to Lync Control Panel \ Voice Routing \ Voice Policy and open any policy or create a new one. You will see that you have the option to View or Create a PSTNUsage.

PSTNUsage is a container for Voice Routes.

After creating Voice Policies, Voice Routes, Trunk configs I tried looking for a way to Create A New PSTNUsage.

I know that lyncoptimizer.com offers a downloadable ps1 script that I looked at and I found the syntax he used to create the PSTNUsage.

I attached a downlaoad of the PS1 file, using Notepad++ array creation starts at line 432. This is part 1 -

# Create an editable array of all NANPA countries
$NANPACountries =  'AI','AN','AS','BA','BD','BM','BV','CA','CQ','DM','DR','GN','GU','JM','KA','LC','MP','PR','RT','SM','TC','TT','US','VI','ZF'
[System.Collections.ArrayList]$NANPACountries = $NANPACountries
# Remove the source country from the list $NANPACountries.Remove('US')

Part 2 may be trickier. Trying with -ExpandProperty is fine but the only property displayed is the -ExpandedProperty and it does not accept more than 1 entry.

What I need is a CSV or TXT file with both the Identity and PSTNUsage properties populated, because I need to know, what PSTNUsage is assigned per Voice Policy.

Here is what I started with:

# $d = Get-CsVoicePolicy -Identity "Tag:HQ1-TestPolicy" | Select-Object -Property  Identity,PstnUsages –ExpandProperty PstnUsages

My goal is to remove all of the PSTNUsages, and add them back in the proper sort order.

Inside of 1 Voice Policy there can multiple PSTNUsage to provide DR fail-over for outbound call routing.

This is the information I would like.

$a = Get-CsVoicePolicy -Identity Tag:National-CallerID-Helpdesk# | Select-Object Identity
$b = Get-CsVoicePolicy -Identity Tag:National-CallerID-Helpdesk# | Select-Object PstnUsages

Write-Host ($a | Select-Object -ExpandProperty Identity)
Write-Host ($b | Select-Object -ExpandProperty PstnUsages)

######################################################################

Q: 1) Do you have a PowerShell.Org account? If not please create one so that you can answer any questions posted.

  2) You just want to run a report for all Voice Routes and show Identity and PstnUsages right?  Have you tried something like this..?
Get-CsVoicePolicy -Identity Tag:National-CallerID-Helpdesk# | Select-Object Identity,@{name=”PstnUsages”;expression={$_.PstnUsages –Join ','}}

What do you get if you enter this?

Get-CsVoicePolicy -Identity Tag:National-CallerID-Helpdesk# | FL *

A: 1) Yes, creating my account now.

  2)  I want to run the report first.  Then I need to add some PSTN usages to a Voice Policy and sort the PSTN usages with another script/

I am needing to Add PSTN usages to a Voice POLICY, NOT route.