We started our NEC SV9100 deployment planning to have system on 10-46-01 Register Mode Plug and Play mode after deployment, which meant we would not need to save extension on phone.
Half way through we decided we would like to use Manual mode which requires SIP User-ID and Password be saved on phone. As we didn’t want to manually go to each phone to change settings the following script uses the 15-05 export from PcPro and logs into each IP Phone and sets its Extension and Password.
Use carefully as if you get the settings wrong you could disconnect all your phones.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Bulk update NEC ITK Phones saved SIP user-id and Password | |
.DESCRIPTION | |
Will update the saved UserID, Password and Extension on an NEC ITK series phone with the Ext numbr it is registered to an SV9100 system with | |
Requries a CSV export from PCPro SV9100 of 15-05. This contains the Extension to IP address mapping. | |
Assumes the SIP userid and Password is the same for all extensions | |
Only tested on SV9100 AU and ITK-24CG phone. Strongly suggest testing on a single extension before bulk updating | |
.EXAMPLE | |
In SV9100 PCPro -> Reports System data | |
Tick 15-05 -> Export as CSV | |
Update phone username and password below and the SIP account password | |
.NOTES | |
Author: James Rudd | |
Blog : http://jrudd.org/ | |
#> | |
# Phone Login | |
$User = "ADMIN" | |
$Password = "<Pass>" | |
# Export 15-05 Phones List as CSV | |
$CSVfile = "C:\Temp\15-XX(3).csv" | |
# Account Pass | |
$SipPassword = "123456789" | |
$IpPhoneList = Import-csv $CSVfile -Header Extension,Type,MAC,Nickname,IPAddress |Select-Object -Skip 1 | |
# Log Errors | |
$phoneErrors = New-Object System.Collections.Generic.List[System.Object] | |
# Loop over Phones | |
foreach ($phone in $IpPhoneList){ | |
$SipExt = $phone.Extension | |
if($SipExt -notmatch "\d{3}"){ | |
Write-Host "Not a valid Extension ${SipExt} " -ForegroundColor Red | |
$phoneErrors.Add("${SipExt}: Not a valid Extension") | |
continue | |
} | |
$PhoneIP = $phone.IPAddress | |
$phoneBase = "http://$PhoneIP" | |
if($phone.Type -notlike "DT900*"){ | |
Write-Host "Extension ${SipExt} is not a DT Phone $PhoneIP" -ForegroundColor Yellow | |
$phoneErrors.Add("${SipExt}: Not a DT Phone") | |
continue | |
} | |
# Test Ping phone to check up | |
if (-not (Test-Connection -ComputerName $PhoneIP -Quiet)){ | |
Write-Host "Extension ${SipExt} could not ping $PhoneIP" -ForegroundColor Red | |
$phoneErrors.Add("${SipExt}: Could not ping $PhoneIP") | |
continue | |
} | |
# Login to Phone (this will lock the phone) | |
#Referer: http://IP/index.cgi?login=0\r\n | |
$URL = "${phoneBase}/index.cgi?username=${User}&password=${Password}" | |
$R = Invoke-WebRequest -Uri $URL -SessionVariable necPhone -Method GET | |
# Get Session ID | |
#<frame src="./menu.cgi?session=2c4a" name="left" > | |
if ($R.Content -match 'index\.cgi\?session=([\d\w]+)'){ | |
$sessionID=$Matches[1] | |
} else { | |
Write-Host "Unable to get session ID for $SipExt on $PhoneIP" -ForegroundColor Red | |
$phoneErrors.Add("${SipExt}: No Session ID") | |
continue | |
} | |
# Set UserID | |
#http://IP/index.cgi?session=2c4a&set=40a0418&item=359 | |
$URL = "${phoneBase}/index.cgi?session=$sessionID&set=40a0418&item=${SipExt}" | |
$R = Invoke-WebRequest -Uri $URL -WebSession $necPhone | |
# Set Password | |
# /index.cgi?session=2c4a&set=40a0583&item=1234 | |
$URL = "${phoneBase}/index.cgi?session=$sessionID&set=40a0583&item=${SipPassword}" | |
$R = Invoke-WebRequest -Uri $URL -WebSession $necPhone | |
# Set Extension | |
# http://IP/index.cgi?session=2c4a&set=40a041a&item=359 | |
$URL = "${phoneBase}/index.cgi?session=$sessionID&set=40a041a&item=${SipExt}" | |
$R = Invoke-WebRequest -Uri $URL -WebSession $necPhone | |
# Save and Reboot | |
#http://IP/index.cgi?session=2c4a&set=all | |
$URL = "${phoneBase}/index.cgi?session=$sessionID&set=all" | |
$R = Invoke-WebRequest -Uri $URL -WebSession $necPhone | |
Write-Host "Updated Extension $SipExt on $PhoneIP" -ForegroundColor Green | |
} | |
$Errors = $phoneErrors -join "`r`n" | |
Write-Host "Failed Extensions:`r`n$Errors" -ForegroundColor Red |