HardwareQuery.vbs

Couldn’t find the original post/author! Will edit link once I find it again:

Copy/save the below with a *.VBS extension:

Dim strComputer '. is the local PC
 Dim WshShell 'the windows script shell
 Dim strQuery 'the WMI Query to run
 Dim colCompSys 'the win32_ComputerSystem collection
 DIM PCModel 'the trimmed string with the model name
 DIM strSerialNum
 Dim colSMBIOS
 strComputer = InputBox("Please enter a computer name," & vbcrlf & "or a '.' for localhost")
Set WshShell = WScript.CreateObject("WScript.Shell")
 strQuery="SELECT * from Win32_ComputerSystem"
 Set colCompSys=GetObject("WinMgmts://" & strComputer & "/root/cimv2").ExecQuery(strQuery)
For Each WMIProperty in colCompSys
 PCModel = TRIM(WMIProperty.Model)
 PCMake = TRIM(WMIProperty.Manufacturer)
 Next
strQuery="Select * from Win32_SystemEnclosure"
 Set colSMBIOS=GetObject("WinMgmts://" & strComputer & "/root/cimv2").ExecQuery (strQuery)
For Each objSMBIOS in colSMBIOS
 strSerialNum = objSMBIOS.SerialNumber
 Next
WScript.Echo "PC Details: " & VBCrLf & PCMake & VBCrLf & PCModel & VBCrLf & strSerialNum
WScript.Quit
Advertisements