Here is a script I put together that will prompt for a computer name or IP address and if it's connected, it will provide you the serial number (Dell's service tag) and the list of users who have logged onto that computer.
Save as plain text .vbs
DIM strComputer
strComputer = UserInput( "Please computer name OR IP address" )
Function UserInput( myPrompt )
UserInput = InputBox( myPrompt )
End Function
'ping host
IF Ping(strComputer) = False then
Wscript.Echo "Computer " & strComputer & " does not appear to be on the network at this time. Script will quit."
wscript.quit
else
end IF
Function Ping(strHost)
dim objPing, objRetStatus
set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strHost & "'")
for each objRetStatus in objPing
IF IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
Ping = False
'WScript.Echo "Status code is " & objRetStatus.StatusCode
else
Ping = True
WScript.Echo "IP: " & objRetStatus.ProtocolAddress
end IF
next
End Function
'access the WMI service on the remote machine
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'return the BIOS serial number (aka service tag)
Set colBIOS = objWMIService.ExecQuery _
("Select * from Win32_BIOS")
For each objBIOS in colBIOS
Wscript.Echo "Serial Number: " & objBIOS.SerialNumber
Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkLoginProfile")
For Each objItem in colItems
IF Len("Name: ") > 1 AND Left(objItem.Name, 5) = "WVUS\" Then
' Wscript.Echo "Full Name: " & objItem.FullName
Wscript.Echo "Name: " & objItem.Name
else
End if
Next
Tuesday, September 09, 2008
VBS script to collect user names and service tag
Tags: vbs

3 Comments:
Very nice! works like a charm!
awesome thx (final a way to collect some missing serials without lifting my ass :p)
Excellent! Glad to hear it helped.
~theGeek
Post a Comment