View/Download Get-UnityLicense.ps1 Script
Many large companies and universities use Cisco Unity for their voicemail system. Cisco provides some sample vbscript code to programatically interface with Unity, but so far they haven’t provided any Powershell cmdlets. This function connects via HTTP to a Unity server and returns license information as a PSCustomObject.
Note: This post refers to the full Cisco Unity, not Unity Express.
Unity provides its current license information on an XML page available through IIS. Because Powershell is built on .NET, it has very good support for HTTP and XML so this was actually a very simple function to write.
First we have to download the web page by initializing a System.Net.Webclient object, and calling the DownloadString method with the URL that we want.
$webContent = new-object net.webclient $page = $webContent.DownloadString("http://$server/avxml/effectivelicense.asp")
The XML that is returned has some whitespace at the top of the page that needs to be stripped out. We use a simple RegEx to strip it out so that .NET doesn’t complain about it. Then, converting the page into an XML object is as simple as casting it with [xml].
$page = $page -replace "^.`n" $license = [xml]$page
Finally, we just store the various XML elements in a PSCustomObject and let it pass to the pipeline.
new-object psobject | add-member -memberType NoteProperty -name LicLanguagesMax -value $license.AvXmlLicData.Licenses.LicLanguagesMax -passthru | add-member -memberType NoteProperty -name LicMaxMsgRecLenIsLicensed -value $license.AvXmlLicData.Licenses.LicMaxMsgRecLenIsLicensed -passthru | add-member -memberType NoteProperty -name LicPoolingIsEnabled -value $license.AvXmlLicData.Licenses.LicPoolingIsEnabled -passthru | add-member -memberType NoteProperty -name LicSubscribersMax -value $license.AvXmlLicData.Licenses.LicSubscribersMax -passthru | add-member -memberType NoteProperty -name LicUMSubscribersMax -value $license.AvXmlLicData.Licenses.LicUMSubscribersMax -passthru | add-member -memberType NoteProperty -name LicVMISubscribersMax -value $license.AvXmlLicData.Licenses.LicVMISubscribersMax -passthru | add-member -memberType NoteProperty -name LicVoicePortsMax -value $license.AvXmlLicData.Licenses.LicVoicePortsMax -passthru | add-member -memberType NoteProperty -name AvLicUtilizationSecondaryServer -value $license.AvXmlLicData.Utilization.AvLicUtilizationSecondaryServer -passthru | add-member -memberType NoteProperty -name AvLicUtilizationSubscribers -value $license.AvXmlLicData.Utilization.AvLicUtilizationSubscribers -passthru | add-member -memberType NoteProperty -name AvLicUtilizationVMISubscribers -value $license.AvXmlLicData.Utilization.AvLicUtilizationVMISubscribers -passthru
The sample output looks like this:
LicLanguagesMax : 2 LicMaxMsgRecLenIsLicensed : 1 LicPoolingIsEnabled : 1 LicSubscribersMax : 15500 LicUMSubscribersMax : 0 LicVMISubscribersMax : 0 LicVoicePortsMax : 96 AvLicUtilizationSecondaryServer : 0 AvLicUtilizationSubscribers : 8190 AvLicUtilizationVMISubscribers : 0
Enjoy! :)
- Robbie