I cam across an issue where a customer needed to update a bunch of snom 300 phones to the latest OCS firmware but couldn’t use DHCP to dish out the firmware (which is a much easier option).
After playing around with the manual update process with the WebUI I thought I could probably send HTTP strings to the phone to get it to do the same thing.
Enter a PowerShell Script that sends HTTP POST strings to do the update. There are still a few buttons to click on the phone so it’s not completely automated, but it does most of the heavy lifting.
I was doing a simple find and replace on the phone IP address, but this could really be a variable.
I wonder if something like this could be used to change the Registrar field on mass if required.
Note: Some lines below may appear ‘wrapped’ on your screen, please copy and paste into your code editor/Notepad to see the lines as they should be. Thanks.
[code lang=”ps”]
# This script hits the webgui of the snom 300 (based on IP in the code), it then does an HTTP post to tell the snom to upgrade its
# firmware. The user must click to update the firmware on the phone
# once they do the phone will reboot
# on reboot the phone still needs a reset, another http get, script will wait for user input
# Tested working 0.1</code>
$url = "http://10.0.1.94/update.htm"
$parameters = "firmware=http://snom.SERVER.local/snom/firmware/snom300-OCS-8.5.4-SIP-f.bin&swload=Load" # your POST parameters
$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.open(‘POST’, $url, $false)
$http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded")
$http_request.setRequestHeader("Content-length", $parameters.length)
$http_request.setRequestHeader("Connection", "close")
$http_request.send($parameters)
$http_request.statusText
Write-Host "Press "tick" on the phone to update firmware, wait for phone to update and reboot then press key to continue …"
write-host "When Key is pressed phone will be reset to complete firmware upgrade"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
write-host "A"
write-host "B"
write-host "C"
# Phone reset
$url = "http://10.0.1.94/advanced_update.htm"
$parameters = "update_policy=settings_only&settings_refresh_timer=0&subscribe_config=off&pnp_config=on&CONFIRM_RESET=Reset" # your POST parameters
$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.open(‘POST’, $url, $false)
$http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded")
$http_request.setRequestHeader("Content-length", $parameters.length)
$http_request.setRequestHeader("Connection", "close")
$http_request.send($parameters)
$http_request.statusText
write=host "Waiting 10 seconds"
start-sleep -s 10
$url = "http://10.0.1.94/confirm.htm"
$parameters = "RESET=Yes" # your POST parameters
$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.open(‘POST’, $url, $false)
$http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded")
$http_request.setRequestHeader("Content-length", $parameters.length)
$http_request.setRequestHeader("Connection", "close")
$http_request.send($parameters)
$http_request.statusText
write-host "Phone should now be rebooting, on reboot it will be ready for sign in information"
[/code]