Manfredtoo
asked on
Re: Remotely Obtain IBM machine Serial Numbers & Machine type For Multiple PCs
hi experts
i am looking for a solution that is able to help me remotely obtain machine type and serial number from the IBM machines... thanks inadvance
i am looking for a solution that is able to help me remotely obtain machine type and serial number from the IBM machines... thanks inadvance
ASKER
hi RobSampson
i manage to obtain the serial number by changing the "win32_BaseBoard" to "win32_Bios". well my objective is to obtain all the ibm serial number with the network. is there a script whereas it able to scan and showing the result containing machine hostname, ip address, machine serial and machine type?
cheers
i manage to obtain the serial number by changing the "win32_BaseBoard" to "win32_Bios". well my objective is to obtain all the ibm serial number with the network. is there a script whereas it able to scan and showing the result containing machine hostname, ip address, machine serial and machine type?
cheers
Yes, that can be done using a list of computers obtained from your AD. I would set it up to Ping each computer to see if it's on, then get the data, and output to CSV.
Or, to avoid a scenario where the computer is not on, you could place the script in a Login script instead, and write the data to a network share, into a file name of each PC's serial number (or logon name). This needs to be individual files to avoid multiple access problems.....
Which would you prefer?
Regards,
Rob.
Or, to avoid a scenario where the computer is not on, you could place the script in a Login script instead, and write the data to a network share, into a file name of each PC's serial number (or logon name). This needs to be individual files to avoid multiple access problems.....
Which would you prefer?
Regards,
Rob.
ASKER
well i prefer the 1st option u gave me by pinging to each computer to obtain information. i would like to check with u, can it be done if i reference the list PCs from a .txt file.
Yes, a text file is just as easy, plus you have more control over the PCs you check. Also this way you can output non-contactable PCs to another text file for input later. I'll work on this script.....
Regards,
Rob.
Regards,
Rob.
ASKER
thanks robsampson
Hi, try this VBS file. Paste the text into Notepad, then "Save as" a file called Get_Details.vbs or something similar with a VBS extension.
Then, drag the text file with computer names in it onto the VBS file, and it will process it.
The output is a CSV file for the computers it could contact, and a plain text file with one computer name per line of computers it could not contact, for you to drag back onto the script later.
'===================
If WScript.Arguments.Count = 0 Then
MsgBox "Please drag a text file that contains computer names onto this script file for processing."
WScript.Quit
End If
strInputFile = WScript.Arguments.Item(0)
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Const intForReading = 1
Set objInputFile = objFSO.OpenTextFile(strInp utFile, intForReading, False)
strResultsFile = Replace(WScript.ScriptFull Name, WScript.ScriptName, "") & "Results_" & Replace(TimeNow(Now), "-", "") & ".csv"
strNoContactFile = Replace(WScript.ScriptFull Name, WScript.ScriptName, "") & "NoContact_" & Replace(TimeNow(Now), "-", "") & ".txt"
Set objOutputFile = objFSO.CreateTextFile(strR esultsFile , True)
objOutputFile.Write "Host Name,IP Address(es),Serial Number,Model"
Set objNoContactFile = objFSO.CreateTextFile(strN oContactFi le, True)
While Not objInputFile.AtEndOfStream
strComputer = objInputFile.ReadLine
If Ping(strComputer) = True Then
Set objWMIService = GetObject("winmgmts:{imper sonationLe vel=impers onate}!\\" & strComputer & "\root\cimv2")
' hostname, ip address, machine serial and machine type
' GET THE IP ADDRESS(ES)
Set colComputerIP = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfig uration")
strIPAddress = ""
For Each IPConfig in colComputerIP
If Not IsNull(IPConfig.IPAddress) Then
For intIPCount = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
If strIPAddress = "" Then
strIPAddress = IPConfig.IPAddress(intIPCo unt)
Else
strIPAddress = strIPAddress & ";" & IPConfig.IPAddress(intIPCo unt)
End If
Next
End If
Next
' GET THE SERIAL NUMBER
Set colBIOS = objWMIService.ExecQuery _
("Select SerialNumber from Win32_BIOS")
For Each objBIOS In colBIOS
strSN = strSN & objBIOS.SerialNumber
Next
' GET THE COMPUTER MODEL AND HOSTNAME
Set colComputer = objWMIService.ExecQuery _
("Select Model, Name from Win32_ComputerSystem")
For Each objComp In colComputer
strModel = objComp.Model
strHostname = objComp.Name
Next
objOutputFile.Write VbCrLf & Trim(strHostname) & "," & Trim(strIPAddress) & "," & Trim(strSN) & "," & Trim(strModel)
Else
objNoContactFile.WriteLine Trim(strComputer)
End If
Wend
objInputFile.Close
objOutputFile.Close
objNoContactFile.Close
Set objInputFile = Nothing
Set objOutputFile = Nothing
Set objNoContactFile = Nothing
MsgBox "Finished processing the input file." & VbCrLf & "Results are in: " & strResultsFile & VbCrLf & "PCs not found: " & strNoContactFile
Function Ping(strComputer)
Dim objShell, boolCode
Set objShell = CreateObject("WScript.Shel l")
boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
If boolCode = 0 Then
Ping = True
Else
Ping = False
End If
End Function
Function TimeNow(dDateTime)
TimeNow = Year(Now) & "-" &_
Right("00" & Month(Now), 2) & "-" &_
Right("00" & Day(Now), 2) & "-" &_
Right("00" & Hour(Now), 2) & "-" &_
Right("00" & Minute(Now), 2) & "-" &_
Right("00" & Second(Now), 2)
End Function
'===================
Regards,
Rob.
Then, drag the text file with computer names in it onto the VBS file, and it will process it.
The output is a CSV file for the computers it could contact, and a plain text file with one computer name per line of computers it could not contact, for you to drag back onto the script later.
'===================
If WScript.Arguments.Count = 0 Then
MsgBox "Please drag a text file that contains computer names onto this script file for processing."
WScript.Quit
End If
strInputFile = WScript.Arguments.Item(0)
Set objFSO = CreateObject("Scripting.Fi
Const intForReading = 1
Set objInputFile = objFSO.OpenTextFile(strInp
strResultsFile = Replace(WScript.ScriptFull
strNoContactFile = Replace(WScript.ScriptFull
Set objOutputFile = objFSO.CreateTextFile(strR
objOutputFile.Write "Host Name,IP Address(es),Serial Number,Model"
Set objNoContactFile = objFSO.CreateTextFile(strN
While Not objInputFile.AtEndOfStream
strComputer = objInputFile.ReadLine
If Ping(strComputer) = True Then
Set objWMIService = GetObject("winmgmts:{imper
' hostname, ip address, machine serial and machine type
' GET THE IP ADDRESS(ES)
Set colComputerIP = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfig
strIPAddress = ""
For Each IPConfig in colComputerIP
If Not IsNull(IPConfig.IPAddress)
For intIPCount = LBound(IPConfig.IPAddress)
If strIPAddress = "" Then
strIPAddress = IPConfig.IPAddress(intIPCo
Else
strIPAddress = strIPAddress & ";" & IPConfig.IPAddress(intIPCo
End If
Next
End If
Next
' GET THE SERIAL NUMBER
Set colBIOS = objWMIService.ExecQuery _
("Select SerialNumber from Win32_BIOS")
For Each objBIOS In colBIOS
strSN = strSN & objBIOS.SerialNumber
Next
' GET THE COMPUTER MODEL AND HOSTNAME
Set colComputer = objWMIService.ExecQuery _
("Select Model, Name from Win32_ComputerSystem")
For Each objComp In colComputer
strModel = objComp.Model
strHostname = objComp.Name
Next
objOutputFile.Write VbCrLf & Trim(strHostname) & "," & Trim(strIPAddress) & "," & Trim(strSN) & "," & Trim(strModel)
Else
objNoContactFile.WriteLine
End If
Wend
objInputFile.Close
objOutputFile.Close
objNoContactFile.Close
Set objInputFile = Nothing
Set objOutputFile = Nothing
Set objNoContactFile = Nothing
MsgBox "Finished processing the input file." & VbCrLf & "Results are in: " & strResultsFile & VbCrLf & "PCs not found: " & strNoContactFile
Function Ping(strComputer)
Dim objShell, boolCode
Set objShell = CreateObject("WScript.Shel
boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
If boolCode = 0 Then
Ping = True
Else
Ping = False
End If
End Function
Function TimeNow(dDateTime)
TimeNow = Year(Now) & "-" &_
Right("00" & Month(Now), 2) & "-" &_
Right("00" & Day(Now), 2) & "-" &_
Right("00" & Hour(Now), 2) & "-" &_
Right("00" & Minute(Now), 2) & "-" &_
Right("00" & Second(Now), 2)
End Function
'===================
Regards,
Rob.
ASKER
hi robsampon
thanks for the script, its amazing. well i have couple of problems or should i say touch up =)
firstly it shows Line:19 char:13 error: permission denial 'Getobject' code:800A0046 source: microsoft vbscript runtime error while scanning half way thru guess for those pc does not allow to access cimv2. juz to update not all pc in my environment are ibm machines therefore is it possible to ignore and proceed it on the plotting of the data?
secondly, it would be the serial numbers all append together, as in the serial will not flush off, it takes the previous serial and append the current serial
cheers
thanks for the script, its amazing. well i have couple of problems or should i say touch up =)
firstly it shows Line:19 char:13 error: permission denial 'Getobject' code:800A0046 source: microsoft vbscript runtime error while scanning half way thru guess for those pc does not allow to access cimv2. juz to update not all pc in my environment are ibm machines therefore is it possible to ignore and proceed it on the plotting of the data?
secondly, it would be the serial numbers all append together, as in the serial will not flush off, it takes the previous serial and append the current serial
cheers
ASKER
hi rob
i managed to find the error for serial number issue, i mentioned earlier, it due to this statement strSN = strSN & objBIOS.SerialNumber with an extra "strSN &" word. but as for the permission issue could you help me look into it? whereas i guess when it ping its gets reply from the pc but not able to access WMI.
i managed to find the error for serial number issue, i mentioned earlier, it due to this statement strSN = strSN & objBIOS.SerialNumber with an extra "strSN &" word. but as for the permission issue could you help me look into it? whereas i guess when it ping its gets reply from the pc but not able to access WMI.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi rob
thanks so much for adding the error checking for me. thanks you so much for your help. it works great.
thanks so much for adding the error checking for me. thanks you so much for your help. it works great.
This is one excellent script Rob
Thanks Sharath, it's good to just drag a text file onto the script....works pretty well.....
Rob.
Rob.
ASKER
rob indeed its a very cool script. =)
Hi !
Nice script .. really like it.
I'm pushing an update to all my pc and in my log file it's creating a txt with computername username date time but i would like to include model and serial number. All IBM machine.
here's my log.bat
@echo off
for /f %%i in ('time /t') do set Heure=%%i
for /f "delims= tokens=1,2" %%i in ('date /t') do set Calendrier=%%i %%j
echo %computername%-%username% %Calendrier% %Heure% >> "J:\GENASDV2\Install Logs\sygate\log.txt"
How do I include the serial number and model type.
Nice script .. really like it.
I'm pushing an update to all my pc and in my log file it's creating a txt with computername username date time but i would like to include model and serial number. All IBM machine.
here's my log.bat
@echo off
for /f %%i in ('time /t') do set Heure=%%i
for /f "delims= tokens=1,2" %%i in ('date /t') do set Calendrier=%%i %%j
echo %computername%-%username% %Calendrier% %Heure% >> "J:\GENASDV2\Install Logs\sygate\log.txt"
How do I include the serial number and model type.
You rock man. It is such a handy script. Its make my life easy.
I know this was a while ago but thanks, great!
Rob, just wanted to say thanks as well. Great script!
I just joined Experts Exchange today and this was the first thing I ran across. I must say "This script is Flippin amazing" Thanks Rob!
'=========
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_Bas
For Each obj In objs
sAns = sAns & obj.SerialNumber
If sAns < objs.Count Then sAns = sAns & ","
Next
MBSerialNumber = sAns
MsgBox MBSerialNumber
'=========
Regards,
Rob.