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.

Limitations:

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.

Conclusion:

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

About these ads

2 thoughts on “Retrieving serial numbers remotely over the network

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s