Retrieving serial numbers remotely over the network

Lets say the CIO of you company says he’d like to have all the neglected inventory spread sheets updated by the end of the month. You look at the portion of the workstation spreadsheet you’re responsible for and find that your lazy ass has not updated it in quite some time. It sucks to have to go to every computer one by one and read the little sticker with the serial number, so lets do it remotely!

Step one, the VBS script:

I found this on the internet a while ago, don’t remember the source and am too lazy to look. But lets just say I take no credit for writing this. Anyway, create a .vbs file and paste this into it:

ComputerName = InputBox(“Enter the name of the computer you wish to query”)

winmgmt1 = “winmgmts:{impersonationLevel=impersonate}!//”& ComputerName &””

‘WScript.Echo winmgmt1

Set SNSet = GetObject( winmgmt1 ).InstancesOf (“Win32_BIOS”)

for each SN in SNSet MsgBox “The serial number for the specified computer is: ” & SN.SerialNumber Next

This simple little script will prompt you for a computer name or IP that is on your domain and when you enter that it will return the serial number of the PC. You didn’t even have to leave your desk. You can also leave the input field blank to get the serial of the PC you are currently running the script on.

If we are talking about PCs with no Windows firewall enabled, you needn’t worry about step 2. Otherwise, read on.

Step two, the only problem:

The only issue I quickly found was that the Windows Firewall on the remote PC (the one you’re trying to get the serial number from) will block the WMI request. You can, of course, disable the firewall on all your client PCs… but that is not the greatest option.

I discovered, thanks to this site, that all you need to do is allow Remote Admin WMI requests through the windows firewall. I’m sure this can be done via a GPO, but lets say for the sake of argument that you aren’t that comfortable with group policy, and/or your boss wants to be the only one to setup new GPOs and can’t be bothered with this.

Well, there is a simple command line that will change this setting for you:

netsh firewall set service RemoteAdmin enable

Add this to your users (.bat file) login script, or to any batch file and it will open up the Windows firewall to allow the script shown above access to get the S/N. If you want to remove this for whatever reason once you have all the info you need the same command, but replacing enable with disable will return it to default.


I’ve only used this for Windows 2000, XP, and 2003. So I can’t confirm or deny that it will work for other versions of Windows. As a .VBS script, I would also imagine that other OS’s than windows will not support this. Also, one last thing, it seem that PC you are querying from and the remote client need to be members of the same domain for this to work. Oh, and the remote PC needs to be turned on. Duh.


With all these things in mind, I found this script to be immensely helpful. In my job, I have PCs that are at other locations, some of which are a good drive away. Since I was too lazy to keep my inventory up to date in the first place, this helped my out to easily get the S/N’s I was missing remotely without the end users even noticing I did anything. I accomplished this all from the comfort of my own desk.

I hope this is helpful to you as well.

-Dave out

4 thoughts on “Retrieving serial numbers remotely over the network

  1. I’m a year late in replying to this comment, but I can confirm that the script works on Windows 7. The only thing that is probably different is the “step two” part. We’re not running Windows firewall on the machines, so this was a not issue in my new test.

    I just tested it in the same environment as when I originally posted this, just that we’ve obviously upgraded to Windows 7 since then. The same command for step two may still work under W7, but I don’t really have time to test it.

    If anyone want to comment on this, feel free.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s