Those days a customer asked me to create a limited access to IPO for human ressources department to check for used and free extensions. Every time new staff is hired HR decides what extension the new user will get.
The challenge
The challenge was to find a way to create a security user with that restricted and read read only access.
The worst option would be to deploy another installation of IP Office Manager on the department computer. That way the user would be able to login and check the user numbers for groups and users. Works for Server Edition solutions were you have a global user list but will be difficult if several IP500 control units are connected to a SCN solution. Another bad thing is that someone always has to ensure that not only administrators but also HR has an actual Manager installed. It is also not possible to restrict access so far that only user and group extensions are visible.
The second option would be to give them access to WebManager. That doesn’t need a local installation. Luckily Avaya gave us the opportunity to restrict also the rights of WebManagement. But it is also not possible to restrict it as far as needed. The limitations for SCN solutions are the same again.
Thanks to Joe for sharing the information how to get a XML list of users and groups through a HTTP request from IP Office. The important URLs to get a full user list and a hunt group list are the following guessing IP Office has IP address 10.10.10.10:
http://10.10.10.10/system/user/scn_user_list and
http://10.10.10.10/system/huntgroup/scn_huntgroup_list
So I decided to download those lists as XML files and extract the data with a small Powershell script.
The implementation
I will not describe the script in every single detail. In short we do the following steps:
- Define variables for IP address, work directory and a target file name
- Check if IP Office is reachable and ask if another IP address should be used
- Create the work directory if needed and download the lists
- Extract the needed data from XML
- Sort the data, write it into a HTML file and open the file
Define variables
# A few variables # $ipoaddress will be used as suggested default IP address $ipoaddress = "10.10.10.10" $htmlpath = "C:\temp" $htmlfile = "HtmlReport.html"
Get IP address of IPO
Here we run a loop that asks for the IP Office’s IP address (Read-Host). After the user decides to either enter the IP or use the default one the reachability of that address is checked (Test-Connection). If it can be reached the loop ends, if not it will ask the user again to enter an IP address until it can be reached.
# Ensure to run loop at least once $reach = $false while ($reach -eq $false) { Write-Output "IP address of IP Office is needed" # Ask to change IPO IP address $prompt = "Enter IP address of primary server or hit Enter to use the default [" + $ipoaddress + "]" #Clear-Variable -Name ipoip $ipoip = Read-Host -Prompt $prompt # Use value of $ipoaddress if nothing is entered or use the value that has been entered # Check if the used IP address is reachable by ping if ($ipoip -eq "") { # Test connection to IPO if (Test-Connection $ipoaddress -Count 1 -Quiet) { $reach = $true } } else { $ipoaddress = $ipoip # Test connection to IPO if (Test-Connection $ipoaddress -Count 1 -Quiet) { $reach = $true } } Clear-Host if ($reach -ne $true) { Write-Output "IP Office is not reachable" Write-Output "" } }
Create work directory if needed
The scripts checks if the work directory we set in the variables section exists. If it is not there it will create the directory.
# Create directory if it doesn´t exist If ($(Test-Path $htmlpath) -eq $false){ New-Item -Path $htmlpath -ItemType Directory }
Download the lists
The script checks if the defined work directory is already available (Test-Path) and creates it (New-Item) if necessary. Then the two lists are downloaded as XML file.
# Implement web client $wc = New-Object System.Net.WebClient # Get user list from IPO $url = "http://" + $ipoaddress + "/system/user/scn_user_list" $output = $htmlpath + "\scn_user_list.xml" $wc.DownloadFile($url, $output) # Get group list from IPO $url = "http://" + $ipoaddress + "/system/huntgroup/scn_huntgroup_list" $output = $htmlpath + "\scn_group_list.xml" $wc.DownloadFile($url, $output)
Extract data
Here the data will be extracted (Get-Content). Each list into a single variable. Later the two lists will be merged into a single variable.
# Extract users from XML file [xml]$xmlfile = Get-Content $output $xmlfile.GetType().FullName $a = $xmlfile.user_list.list.user # Extract groups from XML file [xml]$xmlfile = Get-Content $output $xmlfile.GetType().FullName $b = $xmlfile.huntgroup_list.list.group
Sort and export data
Last step is to export the data into a HTML file (ConvertTo-Html). To make it easier to check for free extensions the list is sorted (Sort-Object) by numbers. The script will finish it’s work by opening the HTML file (Invoke-Item) with the default browser.
# Write users and groups into HTML file $c | Sort-Object -Property extn | select @{Expression={$_.extn};Label="Nebenstelle"},@{Expression={$_.name};Label="Name"},@{Expression={$_.fname};Label="Vollständiger Name"} | ConvertTo-Html | Set-Content $htmlfile
In complete here is the full script:
# A few variables # $ipoaddress will be used as suggested default IP address $ipoaddress = "10.10.10.10" $htmlpath = "C:\temp" $htmlfile = "HtmlReport.html" # Ensure to run loop at least once $reach = $false while ($reach -eq $false) { Write-Output "IP address of IP Office is needed" # Ask to change IPO IP address $prompt = "Enter IP address of primary server or hit Enter to use the default [" + $ipoaddress + "]" #Clear-Variable -Name ipoip $ipoip = Read-Host -Prompt $prompt # Use value of $ipoaddress if nothing is entered or use the value that has been entered # Check if the used IP address is reachable by ping if ($ipoip -eq "") { # Test connection to IPO if (Test-Connection $ipoaddress -Count 1 -Quiet) { $reach = $true } } else { $ipoaddress = $ipoip # Test connection to IPO if (Test-Connection $ipoaddress -Count 1 -Quiet) { $reach = $true } } Clear-Host if ($reach -ne $true) { Write-Output "IP Office is not reachable" Write-Output "" } } # Create directory if it doesn´t exist If ($(Test-Path $htmlpath) -eq $false){ New-Item -Path $htmlpath -ItemType Directory } # Implement web client $wc = New-Object System.Net.WebClient # Get user list from IPO $url = "http://" + $ipoaddress + "/system/user/scn_user_list" $output = $htmlpath + "\scn_user_list.xml" $wc.DownloadFile($url, $output) # Extract users from XML file [xml]$xmlfile = Get-Content $output $xmlfile.GetType().FullName $a = $xmlfile.user_list.list.user # Get group list from IPO $url = "http://" + $ipoaddress + "/system/huntgroup/scn_huntgroup_list" $output = $htmlpath + "\scn_group_list.xml" $wc.DownloadFile($url, $output) # Extract groups from XML file [xml]$xmlfile = Get-Content $output $xmlfile.GetType().FullName $b = $xmlfile.huntgroup_list.list.group $htmlfile = $htmlpath + "\" + $htmlfile # Merge users and groups $c = $a + $b # Write users and groups into HTML file $c | Sort-Object -Property extn | select @{Expression={$_.extn};Label="Nebenstelle"},@{Expression={$_.name};Label="Name"},@{Expression={$_.fname};Label="Vollständiger Name"} | ConvertTo-Html | Set-Content $htmlfile $c.Count # Open HTML file Invoke-Item $htmlfile
Conclusion
As you can see we get a HTML file opened in the standard web browser that lists the extensions of all the users and hunt groups ordered by number. It is now really easy to check what numbers are in use to determine what numbers are still available.
Thanks to Powershell that gives us all methods to get the needed data. The only issue I was not able to solve is to display the user’s full names correct that contain special characters. After searching how to achieve that I figured out that for example German ‘Umlauts’ (in my case ü) are shown wrong in the HTML file. This is caused because HTML needs such characters entered as ü for example. I tried to use the replace function but had no luck. Normal characters could be replaced but Umlauts didn’t work. I hope that will not be a show stopper for you. If anyone has a hint to solve that cosmetic thing please feel free to help me out.
However… feel free to add your comments or ask me for other topics I should cover.
Last but not least I want to share a nice iOS app that helps me to find all information about Powershell commandlets. It describes the commandlet itself, the available and needed parameters and gives a bunch of nice examples. It doesn’t cover only straight forward Powershell tasks but also commandlets that are available for Microsoft Exchange, SharePoint, Azure and others. The app also know about third party commandlets for Vmware PowerCLI, Citrix and Amazon Web Services (AWS).
If you need further help with IP Office you can contact me through my main website: https://www.fwilke.com/home
Do you want to get information about new posts? Subscribe to my Newsletter
Pingback: Updated: Get IP Office extension list - Blog: Florian Wilke