Tom Talks Microsoft Teams and Microsoft 365 news and opinions

Update Snom Phone Firmware with PowerShell and HTTP POST

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&amp;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&amp;settings_refresh_timer=0&amp;subscribe_config=off&amp;pnp_config=on&amp;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]

About the author

Tom Arbuthnot

A Microsoft MVP and Microsoft Certified Master, Tom Arbuthnot is Founder and Principal at Empowering.Cloud as well as a Solutions Director at Pure IP.

Tom stays up to date with industry developments and shares news and his opinions on his Tomtalks.blog, UC Today Microsoft Teams Podcast and email list. He is a regular speaker at events around the world.

Add comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Tom Talks Microsoft Teams and Microsoft 365 news and opinions