**Disclaimer: Use all scripts with caution. I am posting what I personally used. I am not responsible for any issues you may have with the use of the following script.
Recently we came across an issue where we needed to verify all of our active IP Phones in the enterprise by serial number. There was no way that we could find to pull all of this information easily, so I got creative. I know we could have gone through each profile in CM to find it that way, or browsed to the web interface of each phone, but when you have a large amount of phones, that’s just not an option.
The following script is written in PHP. I tossed it on a web server and opened it in chrome. This script will go through and open the following URL for all addresses within a specified class-c network:
This will return some XML data in this form. No authentication is needed to open this as long as HTTP services are enabled. This is my 7960 from my home voice lab:
The script goes through and gathers this information for each address in the class C network of choice and then separates the “important” data for this specific cause. That includes the MAC Address, IP Address, and Serial Number. The output for the subnet is all displayed then right in the browser. There is no need to log in to each device or use any credentials. As long as the HTTP services are enabled on each phone and the URL above can be reached, you are good!
So here is the script in it’s entirety. Forgive me, I’m sure there may have been better ways to code this, but it works!
(It’s standard PHP and able to be edited easily if needed.)
In my case, I saved this as CM-serials.php. To actually run the script, I used the following url:
That will prompt the script to go through the 172.16.1.0/24 subnet for addresses. You change the three octets on the end of the URL to specify the specific network you are focusing on. If you have something larger than a /24, you can just run the scan in multiple different scans (/23, etc). Obviously this will only return data for phones that are on the network currently, so you may have to run at different times of the day to get all of your devices. Once completed, here is what the output will look like:
Blacked out the identifying information for security, but you get the point. There are three columns displayed with the applicable information. From there, you can clean up the data in Excel or something like Notepad++ to get in the specific format that you might need.
If there are any issues with the script, let me know and I’d be happy to take a look at the script to see what’s up, just comment below.