Solved

Remotely Obtain Serial Numbers For Multiple PCs At Once?

Posted on 2007-03-27
8
225 Views
Last Modified: 2011-02-11
I located a vbs script some time ago were I get remotely obtain a machines serial number.

On Error Resume Next
Dim System
if Wscript.Arguments.Count >0 then
sSystem=Wscript.Arguments(0)
end if
ComputerName = InputBox("Enter the name of the computer you wish to query")
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS")
for each SN in SNSet
MsgBox "The serial number for the specified computer is: " & SN.SerialNumber
Next


pause



 Works fine on most pcs.  What I would like to do however is instead of checking 1 by one, I would like to check multiple pcs at once.  Does anyone know how I can do this?

Thanks

0
Comment
Question by:master_windu
  • 5
  • 3
8 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18802851
You could make it work down a text file.  This could be done just in VBS (sirbounty will no doubt help you with that here shortly as...) or you can use a batch file to call your VB script, e.g.

@echo off
REM Save as SerialNums.cmd
set source=complist.txt
set dest=serials.txt
echo ------------%DATE%  %TIME-------------->>%dest%
if not exist "%source%" then echo Unable to find computer list & goto end
for /f "tokens=1" %%a in (complist.txt) do cscript sernum.vbs %%a >> serials.txt
:end

REM sernum.vbs
On Error Resume Next
Dim ComputerName
if Wscript.Arguments.Count >0 then
   ComputerName=Wscript.Arguments(0)
else
   ComputerName = InputBox("Enter the name of the computer you wish to query")
end if
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS")
for each SN in SNSet
    wscript.echo ComputerName,SN.SerialNumber
Next
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18802857
That works down a list in complist.txt, one per line of all your computers.
0
 

Author Comment

by:master_windu
ID: 18804387
thanks

I must be doing something wrong

I created the complist.txt file and placed it in the same dir as the .cmd and vbs file

when I run serialnums.cmd, the cmd window appears with todays date and the word "dest"
the serials.txt file is generated but it only reads.....

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 18806376
OK, sorry made a typo in the entry for %time% as %time caused one of the issues here.  Try this:

@echo off
REM Save as SerialNums.cmd
set source=complist.txt
set dest=serials.txt
echo ------------%DATE%  %TIME%-------------->>%dest%
if not exist "%source%" then echo Unable to find computer list & goto end
for /f "tokens=1" %%a in (%source%) do cscript //nologo sernum.vbs %%a >> %DEST%
:end
start %dest%

REM sernum.vbs
On Error Resume Next
Dim ComputerName
if Wscript.Arguments.Count >0 then
   ComputerName=Wscript.Arguments(0)
else
   ComputerName = InputBox("Enter the name of the computer you wish to query")
end if
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS")
for each SN in SNSet
    wscript.echo ComputerName,SN.SerialNumber
Next
0
 

Author Comment

by:master_windu
ID: 18809847
Thanks. works great as long as i use ip addesses in the complist.txt file.

any way i can use machine names?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18811852
Can your computer resolve the names when you PING them for starters I suppose?  You might have to add them to the file fully qualified, i.e. name.domain.com?
0
 

Author Comment

by:master_windu
ID: 18812192
all is well.  I went back and tried some more machine names and I was able  to get back a serial without the fqdm.

Thanks
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18812266
No problem, glad to help!

Steve
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
powershell script 9 63
Creating An Intelligent Dropdown 8 42
Create Consolidation Sheet 3 38
PowerShell logging 1 14
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question