PowerShell Module for Sonus SBC 1000-2000

It’s finally here!!!! PowerShell module for Sonus SBC 1000/2000. Well it’s not an official one, but one I created out of necessity when managing numerous SBC’s.

Key Features

  1. Built-in cmdlets to query Sonus SBC for transformation tables, transformation entries, systems information, etc.
  2. Built-in cmdlets to create transformation tables and transformation entries
  3. Built-in cmdlets to reboot and backup Sonus SBC
  4. Extensibility – Query, create, modify and delete any UX resource even the one’s which don’t have cmdlets associated!
  5. Scalability – Manage Sonus SBC’s at scale. Query, create, modify and delete resources with extraordinary efficiency. 1 or 100 SBC’s, it doesn’t matter!
  6. Simplicity – Extremely simple to use, logical cmdlet naming and in-depth built-in help.

Pre-requisites

  1. Sonus SBC software should be R3.0 or higher
  2. PowerShell v 3.0 or higher
  3. Ensure you have applied the base version 3.0 license which contains the license for REST
  4. Ensure you have created a username and password for REST. For more details check out: http://www.allthingsuc.co.uk/accessing-sonus-ux-with-rest-apis/

Getting Started

  1. Download the SonusUX PowerShell module from here
  2. Copy the module to your machine. Ideally you want to copy the module to one of the following locations as these are default locations where PowerShell looks for modules when import-module is executed.
    1. C:\Users\YOURUSERNAME\Documents\WindowsPowerShell\Modules
    2. C:\Windows\system32\WindowsPowerShell\v1.0\Modules


  3. Open PowerShell and import the module:
    1. If the module is in one of the above locations (where PowerShell searches), you can just execute import-module SonusUX
    2. If the module is not in the default location you can execute import-module C:\SonusUX\SonusUX.psm1 (replacing the path where you have copied the module to)


  4. To discover what cmdlets are available execute: get-command –module SonusUX. Full PowerShell cmdlet help is available for all cmdlets.


  5. The first cmdlet you need to use is connect-uxgateway. The screenshot below shows the complete syntax. Once connected you can start using other cmdlets.


Cmdlet Execution

Below is the output of some of the cmdlets:

  1. Get call statistics from Sonus SBC

    Get-uxsystemscallstats


  2. Get system information

    Get-uxsysteminfo


  3. Get transformation table

    Get-uxtransformationtable


  4. Get transformation table entries from a specified Transformation table

    get-uxtransformationentry -uxtransformationtableid 11


  5. Create Transformation table

    new-uxtransformationtable -Description “LyncToPBX”

  6. Create Transformation entry

    new-uxtransformationentry -TransformationTableId 9 -InputFieldType 3 -InputFieldValue ‘(.*)’ -OutputFieldType 3 -OutputFieldValue ‘\1’ -Description “PassthroughCLI” -MatchType 0

Advanced Cmdlet Execution

And just to get you started, below are some Powershell one liners you can use to query multiple SBC’s!

  1. Query number of calls currently up on the SBC’s

    “lyncgwy1”, “lyncgwy2” | % { connect-uxgateway -uxhostname $_ -uxusername restuser -uxpassword Password01 ; (get-uxsystemcallstats).rt_NumCallCurrentlyUp}

  2. Query the Hardware ID of the SBC’s

    “lyncgwy1”, “lyncgwy2” | % { connect-uxgateway -uxhostname $_ -uxusername restuser -uxpassword Password01 ; (get-uxsysteminfo).rt_Chassis_Hardware_ID}

  3. The below command will query the gateways in Lync topology and than query them for all the transformation tables

    Get-CsService -PstnGateway | select -ExpandProperty poolfqdn | % { connect-uxgateway -uxhostname $_ -uxusername restuser -uxpassword Password01; write-host “`n$uxhostname” -ForegroundColor Green ;get-uxtransformationtable}


  4. The below command will query the gateways in Lync topology and create backup of its configuration

    Get-CsService -PstnGateway | select -ExpandProperty poolfqdn | % {connect-uxgateway -uxhostname $_ -uxusername restuser -uxpassword Password01; invoke-uxbackup -backupdestination c:\UXbackup -backupfilename $_ }

  5. Copy transformation table entries from one transformation table to another on the Sonus SBC

    get-uxtransformationentry -uxtransformationtableid 12 | Sort-Object sequenceid |%{ new-uxtransformationentry -TransformationTableId 1 -InputFieldType $_.inputfield -InputFieldValue $_.inputfieldvalue -OutputFieldType $_.outputfield -OutputFieldValue $_.outputfieldvalue -Description $_.description -MatchType $_.matchtype }

  6. Copy transformation table entries from one Sonus SBC to another (Ok, now this certainly isn’t a one liner and I wouldn’t really recommened to use this method as it creates are new connection on destination Sonus SBC for every entry it creates from source, I rather prefer doing a little script, but hey, I just wanted to demonstrate how powerful this is!)

    connect-uxgateway -uxhostname Sourcelyncgw1 -uxusername restuser -uxpassword Password01;get-uxtransformationentry -uxtransformationtableid 1 | Sort-Object sequenceid | % {connect-uxgateway -uxhostname Destlyncgw1 -uxusername restuser -uxpassword Password02;new-uxtransformationentry -TransformationTableId 1 -InputFieldType $_.inputfield -InputFieldValue $_.inputfieldvalue -OutputFieldType $_.outputfield -OutputFieldValue $_.outputfieldvalue -Description $_.description -MatchType $_.matchtype}

As you can see the possibilities are immense and hopefully this module will help you to be more efficient at deploying and managing Sonus devices. You can also quite easily extend the module (leverage get-command *-uxresource cmdlets to make your life easy!) and create advanced scripts using the existing cmdlets. Please feel free to provide any feedback or let me know what other cmdlets you would like to see in future updates or if you update the module please send me a copy to share with the community.

Enjoy!

Vik

7 Thoughts on “PowerShell Module for Sonus SBC 1000-2000

  1. Pingback: PowerShell Module for Sonus SBC 1000-2000 | allthingsuc | JC's Blog-O-Gibberish

  2. Eric Akeret on 29/01/2014 at 13:29 said:

    Hi Vik,
    first of all congratulations for this excellent work. I’ve downloaded the PS file and managed to run the first get-command -module SonusUX sucessfully.
    I’m running V3.1 on many UX2000 and licensed for REST, I’ve defined a rest user profile

    However when I try the connect command
    >connect-uxgateway -uxhostname 10.54.126.6 -uxusername rest -uxpassword sonus2013

    I’m getting the following error msg

    10.54.126.6 – Unable to connect to 10.54.126.6. Verify 10.54.126.6 is
    accessible on the network. The error message returned is Unable to connect to
    the remote server
    At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\sonusUX\sonusUX.psm1:84
    char:3
    + throw “$uxhostname – Unable to connect to $uxhostname. Verify
    $uxhostname is a …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~~~~~~~
    + CategoryInfo : OperationStopped: (10.54.126.6 – U…e remote se
    rver:String) [], RuntimeException
    + FullyQualifiedErrorId : 10.54.126.6 – Unable to connect to 10.54.126.6.
    Verify 10.54.126.6 is accessible on the network. The error message returne
    d is Unable to connect to the remote server

    Thanks for your help
    Best Rgds from Switzerland

    • Vik Jaswal on 29/01/2014 at 14:41 said:

      Eric,
      Its reporting “Unable to connect to the remote server”. Essentially it cannot even reach the Sonus (so its failing before any authentication takes place). Could you navigate to that IP address via the browser (https://10.54.126.6) and verify you are connecting to the Sonus gateway. Ensure there is no firewall which may be blocking the connection.
      Thanks,
      Vik

  3. Dan on 11/03/2014 at 15:58 said:

    ux-transformationtable is great! Would be good to have routing cmdlets, any plans?

    • Vik Jaswal on 12/03/2014 at 10:19 said:

      Great you found it useful. Planning to add numerous other cmdlets in next couple of months generally related to Reporting. No immediate plans to add routing cmdlets but definitely add them eventually.
      Vik

  4. Pingback: Building Sonus Transformation Tables…fast…very fast!!! | allthingsuc

  5. Pingback: Using Powershell 3.0 and REST to access Sonus SBC1000/2000 | CUsoon

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve this to prove you are not a bot * Time limit is exhausted. Please reload the CAPTCHA.

Post Navigation