Friday, May 24, 2013

Pull computer information remotely in cmd, using WMIC

I recently had a request to pull the serial number for one of our remote workstation.  I wouldn't be able to get hands on the machine, and figured I should be able to do this without calling the user and asking them to flip over their machine.
Enter WMIC
My first search "serial number through cmd" brought me to this site:
http://blogs.technet.com/b/aviraj/archive/2010/08/13/how-to-find-a-machine-serial-number-from-command-prompt-using-wmi.aspx
where I learned the run command was
wmic bios get serialnumber

So I tried it on my computer, success, I got my serial number.  Now... how do I go about getting another computers serial number?  Remember, I would like to avoid calling the user in this scenario.

So I looked up WMIC and found Microsoft's write up on the subject.
Here is Microsoft's write up of WMIC and what it can do:
http://technet.microsoft.com/en-us/library/bb742610.aspx

Under the "Putting WMIC to work" section they have this bit of scripting:
LISTING 1: Code to Display
Results at the
Console from a WMIC Batch File
wmic /node:SERVER1, SERVER4
     cpu get name, caption,
     maxclockspeed, systemname
     /format:textvaluelist.xsl

The part I bolded contained my answer.
The script I ran looked like this:
wmic /node:(computer's ip address) bios get serialnumber
I tried going through the computer name here, but it didn't work.

UPDATE:
I've been poking around with this wmic and figured I could get HDD processor and memory information to start building an upgrade list.
I used these commands to get the info I wanted:

HDD size: wmic /node:(ip address) diskdrive get size

Total installed memory: wmic /node:(ip address) computersystem get totalphysicalmemory

Processor Type:wmic /node:(ip address) cpu get name

Installed Software: wmic /node:(ip address) product get name,version

I had to get software for multiple computers, so instead of copying everything out of the command prompt, I ran this script:

Installed software export to file: wmic /output:c:\(path) /node:(ip address) product get name,version

I supposed one day I'll be able to script these better, but for now I'm running CMD as a network admin account (instead of just running normal, or running as admin, I ran as other user)

No comments:

Post a Comment

Samsung refrigerator not making ice

How I got my stupid fridge to work again. Normally, I press/hold the blue button till it chimes. Well that didn’t work this time. Darn. I re...