Solved

Computer Inventory Via Script - MAC, System Name...

Posted on 2011-02-11
10
935 Views
Last Modified: 2012-05-11
Hello Everyone!

Wondering if there is a script I can use to obtain some computer information. I have about 300 PCs. I would like to obtain the PC MAC, Computer Name, Serial number, Manufacture, Model, CPU type, CPU speed, Ram and Ram Speed. I wanted to see if it was possible to output this inforamtion to a text file as well. I have mostly HPs in inventory. Any suggestions would be appreciated.

Thank You!
0
Comment
Question by:vcampos
10 Comments
 
LVL 4

Expert Comment

by:IceCode
Comment Utility
I wrote this a long time ago, it's probably overkill for you but you can make it work.  It's made to do one machine at a time but could be modified to do a list from a csv pretty easily I think.  Run it and see how you like it.


'****************************************************
'*                                                  *
'*   HelpDesk Computer Analysis                     *
'*   Created: 11/2/05                               *
'*                                                  *
'****************************************************


Set sho = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set nwo = CreateObject("WScript.Network")

FN = wscript.scriptfullname 	'Grabs the full path and name of this script
LenFN = Len(FN) 		'Gets the length of FN
N = wscript.scriptname 		'Gets the only the name of this script
LenN = Len(N) 			'Gets the length of N
DiffN = LenFN - LenN - 1  	'Gets the differnce in length between FN and N
PathN = Mid(FN,1,DiffN)  	'Takes the full name and removes DiffN characters

'====================================================================================================

Dim StrComputer
Dim objReport
Dim strReport
Dim StrFolder
Main

Sub Main
	Getcomputername
	rtnSystemInfo
	rtnIEConnectionSettings
	rtnNetworkProfiles
	rtnPrinterConnections
	rtnStartUpItems
	rtnAutoServicesStopped
	rtnIPInfo
	sho.run Chr(34) & strReport & Chr(34)
End Sub

Sub Getcomputername

	StrComputer = InputBox("Enter Computer Name:","Computer Name:")
  If StrComputer = "" Then wscript.quit
  	
  	On Error Resume Next
		Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
		If err.number <> 0 Then ErrorReport1
  	
' create text file
StrFolder = sho.specialfolders("desktop")
If Not (fso.folderexists(Strfolder & "\HD Comp Reports")) Then
	fso.createfolder(Strfolder & "\HD Comp Reports")
End If
strReport = StrFolder & "\HD Comp Reports\" & StrComputer & ".txt"
Set objReport = fso.createtextfile(strReport)
  	
End Sub

Sub ErrorReport1
	MsgBox("Machine " & Chr(34) & StrComputer & Chr(34) & " is not reachable")
		Main
End Sub

Sub rtnPrinterConnections
'strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

objReport.writeline "Printer Connections"
objReport.writeline "------------------------------------------------------------------------------------"

For Each objPrinter in colInstalledPrinters
    objreport.writeline "  Name: " & objPrinter.Name
    objreport.writeline "  Location: " & objPrinter.Location
    objreport.writeline "  Default: " & objPrinter.Default
    objreport.writeline ""
Next
objreport.writeline ""
End Sub
	
Sub rtnAutoServicesStopped
Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & StrComputer).ExecQuery("select * from Win32_Service where State='Stopped' and StartMode='Auto'")

objReport.writeline "Automatic Services that are Stopped"
objReport.writeline "------------------------------------------------------------------------------------"

For each Service in ServiceSet
	objReport.writeline " - " & Service.DisplayName
next
if ServiceSet.Count = 0 Then objReport.writeline "No services found meeting query criteria."
objReport.writeline ""
objReport.writeline ""
End Sub

Sub rtnStartUpItems
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7
 
'strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
 
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, _
    arrValueNames, arrValueTypes
 
objReport.writeline "Start Up Programs"
objReport.writeline "------------------------------------------------------------------------------------"
 
For i=0 To UBound(arrValueNames)
    objReport.writeline "  Value Name: " & arrValueNames(i)
    
'===> determine data type and write it to the report    
    Select Case arrValueTypes(i)
        Case REG_SZ
            objReport.writeline "    Data Type: String"
        Case REG_EXPAND_SZ
            objReport.writeline "    Data Type: Expanded String"
        Case REG_BINARY
            objReport.writeline "    Data Type: Binary"
        Case REG_DWORD
            objReport.writeline "    Data Type: DWORD"
        Case REG_MULTI_SZ
            objReport.writeline "    Data Type: Multi String"
    End Select 
    
'===> read key data and write it to the report
	strValueName = arrValueNames(i)
	oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
	objReport.writeline "    Data: " & strValue
  objReport.writeline ""
Next
    objReport.writeline ""
End Sub	
	
Sub rtnIPInfo
'strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colAdapters = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

objReport.writeline "IP Information"
objReport.writeline "------------------------------------------------------------------------------------"
objReport.writeline ""
n = 1
 
For Each objAdapter in colAdapters
   objReport.writeline "  Network Adapter " & n
   objReport.writeline "  ================="
   objReport.writeline "      Description: " & objAdapter.Description
 
   objReport.writeline "      Physical (MAC) address: " & objAdapter.MACAddress
   objReport.writeline "      Host name:              " & objAdapter.DNSHostName
 
   If Not IsNull(objAdapter.IPAddress) Then
      For i = 0 To UBound(objAdapter.IPAddress)
         objReport.writeline "      IP address:             " & objAdapter.IPAddress(i)
      Next
   End If
 
   If Not IsNull(objAdapter.IPSubnet) Then
      For i = 0 To UBound(objAdapter.IPSubnet)
         objReport.writeline "      Subnet:                 " & objAdapter.IPSubnet(i)
      Next
   End If
 
   If Not IsNull(objAdapter.DefaultIPGateway) Then
      For i = 0 To UBound(objAdapter.DefaultIPGateway)
         objReport.writeline "      Default gateway:        " & _
             objAdapter.DefaultIPGateway(i)
      Next
   End If
 
   objReport.writeline
   objReport.writeline "      DNS"
   objReport.writeline "      ---"
   objReport.writeline "        DNS servers in search order:"
 
   If Not IsNull(objAdapter.DNSServerSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
         objReport.writeline "          " & objAdapter.DNSServerSearchOrder(i)
      Next
   End If
 
   objReport.writeline "        DNS domain: " & objAdapter.DNSDomain
 
   If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
         objReport.writeline "        DNS suffix search list: " & _
             objAdapter.DNSDomainSuffixSearchOrder(i)
      Next
   End If
 
   objReport.writeline
   objReport.writeline "      DHCP"
   objReport.writeline "      ----"
   objReport.writeline "        DHCP enabled:        " & objAdapter.DHCPEnabled
   objReport.writeline "        DHCP server:         " & objAdapter.DHCPServer
 
   If Not IsNull(objAdapter.DHCPLeaseObtained) Then
      utcLeaseObtained = objAdapter.DHCPLeaseObtained
      strLeaseObtained = WMIDateStringToDate2(utcLeaseObtained)
   Else
      strLeaseObtained = ""
   End If
   objReport.writeline "        DHCP lease obtained: " & strLeaseObtained
 
   If Not IsNull(objAdapter.DHCPLeaseExpires) Then
      utcLeaseExpires = objAdapter.DHCPLeaseExpires
      strLeaseExpires = WMIDateStringToDate2(utcLeaseExpires)
   Else
      strLeaseExpires = ""
   End If
   objReport.writeline "        DHCP lease expires:  " & strLeaseExpires
 
   objReport.writeline
   objReport.writeline "      WINS"
   objReport.writeline "      ----"
   objReport.writeline "        Primary WINS server:   " & objAdapter.WINSPrimaryServer
   objReport.writeline "        Secondary WINS server: " & objAdapter.WINSSecondaryServer
   objReport.writeline ""
   objReport.writeline ""
 
   n = n + 1
 
Next
 

	
End Sub

Sub rtnSystemInfo
'strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
objReport.writeline "Report run: " & Now()
objReport.writeline ""
objReport.writeline "System Information"
objReport.writeline "------------------------------------------------------------------------------------"

For Each objOperatingSystem in colSettings 
    objReport.writeline "OS Name: " & objOperatingSystem.Name
    objReport.writeline "Version: " & objOperatingSystem.Version
    objReport.writeline "Service Pack: " & _
        objOperatingSystem.ServicePackMajorVersion _
            & "." & objOperatingSystem.ServicePackMinorVersion
    objReport.writeline "OS Manufacturer: " & objOperatingSystem.Manufacturer
    objReport.writeline "Windows Directory: " & _
        objOperatingSystem.WindowsDirectory
    objReport.writeline "Available Physical Memory: " & _
        objOperatingSystem.FreePhysicalMemory
    objReport.writeline "Total Virtual Memory: " & _
        objOperatingSystem.TotalVirtualMemorySize
    objReport.writeline "Available Virtual Memory: " & _
        objOperatingSystem.FreeVirtualMemory
    objReport.writeline "Size stored in paging files: " & _
        objOperatingSystem.SizeStoredInPagingFiles
Next

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")

For Each objComputer in colSettings 
    objReport.writeline "System Name: " & objComputer.Name
    objReport.writeline "System Manufacturer: " & objComputer.Manufacturer
    objReport.writeline "System Model: " & objComputer.Model
    objReport.writeline "Time Zone: " & objComputer.CurrentTimeZone/60 & " hours from Greenwhich"
    objReport.writeline "Total Physical Memory: " & _
        objComputer.TotalPhysicalMemory
Next

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_Processor")

For Each objProcessor in colSettings 
    objReport.writeline "Processor: " & objProcessor.Description
Next

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")

For Each objBIOS in colSettings 
    objReport.writeline "BIOS Version: " & objBIOS.Version
    objReport.writeline ""
    objReport.writeline ""
Next
End Sub

Sub rtnIEConnectionSettings
'strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_LANSettings")

objReport.writeline "Internet Explorer LAN Settings"
objReport.writeline "------------------------------------------------------------------------------------"

For Each strIESetting in colIESettings
    objReport.writeline "Autoconfiguration proxy: " & strIESetting.AutoConfigProxy
    objReport.writeline "Autoconfiguration URL: " & strIESetting.AutoConfigURL
    objReport.writeline "Autoconfiguration Proxy detection mode: " & _
        strIESetting.AutoProxyDetectMode
    objReport.writeline "Proxy: " & strIESetting.Proxy
    objReport.writeline "Proxy override: " & strIESetting.ProxyOverride
    objReport.writeline "Proxy server: " & strIESetting.ProxyServer
    objReport.writeline ""
    objReport.writeline ""
Next
End Sub

Sub rtnNetworkProfiles
'On Error Resume Next

'strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkLoginProfile")

objReport.writeline "Network Login Profiles"
objReport.writeline "------------------------------------------------------------------------------------"
Dim StrAge

For Each objItem in colItems
	If Left(objItem.Caption,2) <> "NT" Then
    dtmWMIDate = objItem.AccountExpires
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objReport.writeline "Account Expires: " & strReturn
    objReport.writeline "Authorization Flags: " & objItem.AuthorizationFlags
    objReport.writeline "Bad Password Count: " & objItem.BadPasswordCount
    objReport.writeline "Caption: " & objItem.Caption
    objReport.writeline "Description: " & objItem.Description
    objReport.writeline "Full Name: " & objItem.FullName
    objReport.writeline "Home Directory: " & objItem.HomeDirectory
    objReport.writeline "Home Directory Drive: " & objItem.HomeDirectoryDrive
    dtmWMIDate = objItem.LastLogoff
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objReport.writeline "Last Logoff: " & strReturn
    dtmWMIDate = objItem.LastLogon
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objReport.writeline "Last Logon: " & strReturn
    objReport.writeline "Logon Hours: " & objItem.LogonHours
    objReport.writeline "Maximum Storage: " & objItem.MaximumStorage
    objReport.writeline "Name: " & objItem.Name
    objReport.writeline "Number Of Logons: " & objItem.NumberOfLogons     
    dtmWMIDate = objItem.PasswordExpires
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objReport.writeline "Password Expires: " & strReturn
    objReport.writeline "Script Path: " & objItem.ScriptPath
    objReport.writeline ""
    objReport.writeline ""
  End If
Next
End Sub

Function WMIDateStringToDate(dtmWMIDate)
On Error Resume Next
    If Not IsNull(dtmWMIDate) Then
    WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
         Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
             & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
                 Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, 13, 2))
    End If
End Function

Function WMIDateStringToDate2(utcDate)
On Error Resume Next
   WMIDateStringToDate2 = CDate(Mid(utcDate, 5, 2)  & "/" & _
       Mid(utcDate, 7, 2)  & "/" & _
           Left(utcDate, 4)    & " " & _
               Mid (utcDate, 9, 2) & ":" & _
                   Mid(utcDate, 11, 2) & ":" & _
                      Mid(utcDate, 13, 2))
End Function

Open in new window

0
 

Author Comment

by:vcampos
Comment Utility
Wow!  So close.  The only thing I am missing is the serial number, CPU type, CPU speed, Ram, Ram speed. Do you think that is possible? I think we are in the right track.
0
 
LVL 4

Expert Comment

by:IceCode
Comment Utility
Yes, you can just modify to select the things you want.  I'll take a look tomorrow and see if I can fix it up a bit for you.
0
 
LVL 38

Expert Comment

by:Insignificant Volunteer
Comment Utility
Hi vcampos

May I make a suggestion that may make it incredibly easy to create your own *.VBS files that interrogate the system using WMI.

The "Microsoft Scripting Guys" created an application in named "Scriptomatic 2.0" in *.HTA format, which is something like an extended form of HTML that contains scripts which would not be allowed to run in a normal browser.  An HTA file is able to run unrestricted and resembles a dialog that is like a mix of a "DOS" window and a blank web page.

You can download Scriptomatic 2.0 Here:
http://rdsrc.us/ZaO3Gr

You will also see links at the bottom of that page to "WMI Code Creator", to Technet Script Center and Repository, and to Sample Scripts.

Scriptomatic 2.0 may now be a bit outdated for your needs, but essentially what you do is unpack the downloaded "Scriptomatic2.exe" to any folder and double-click on "ScriptomaticV2.hta".  Wait for it to load and it should default to "Root\CIMV2 Namespace", Language = VBScript, and Output Format = Command Prompt.

From the "WMI Class" drop-down list, you scroll to a class that sounds as though it relates to the details you want to retrieve (eg. for RAM "Win32_PhysicalMemory").  It will display the script and you can execute it in a CMD window by clickig the Run button.

Inspect which of the fields contains unnecessary results, close the CMD window, and delete those lines in the script field.  Run again until you get the desired results, and you can then either scroll over and copy the script, or click the Save button to save it (it defaults to C:\Scripts).

To execute a VBS file, just use the command  CScript //NoLogo NameOfFile.vbs

The program executes the script on the computer you are running Scriptomatic on, and you can see this in the line of code:

arrComputers = Array("YourComputerNameHere")

All the scripts begin with this:

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("YourComputerNameHere")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

and then make the call to the WMI Class like this (for "Win32_PhysicalMemory"):

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemory", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

Where dates need to be reported in the output, they add the following to the end:

Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
      WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
      Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
      & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Now, instead of using Scriptomatic 2.0, which is most likely well outdated, I would suggest Rob van der Woude's "WMI Code Generator Version 5.10" here:

http://www.robvanderwoude.com/wmigen.php

It's the same idea, and he acknowledged Scriptomatic 2.0 as the basis for his earlier versions.  Unzip the download to any folder, double-click "WMIGen.hta" and wait for it to load.

Select a suitable looking "WMI Class" by name in the top field.  The "Properties" and "Methods" fields will show the names of the properties and methods available for the selected class.  Don't worry about selecting any of them.  Scroll down and set "Scripting Language" as  "VBScript", and click "Generate Code" which will appear in the "Results" window.

Click "Run WMI Code" and, instead of a "DOS" window showing, the results will appear in the "Result" field.  Unfortunately, unlike Scriptomatic 2.0, you CANNOT edit the script in place.  You have o "Copy to Clipboard", paste it out to a VBS file, make your edits, and test it.

In the scripts that this program generates, you will only be removing unwanted  "WScript.Echo" lines like this:

WScript.Echo "Caption                        : " & objInstance.Caption

Once happy, you can generate new scripts using different "WMI Classes" and append them to others in your *.VBS file.

Each generated script begins with:

' This VBScript code was generated using the WMI Code Generator, Version 5.10
' http://www.robvanderwoude.com/wmigen.php

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly       = &h20

If WScript.Arguments.UnNamed.Count = 1 Then
      strComputer = WScript.Arguments.UnNamed(1)
Else
      strComputer = "."
End If

You only need that ONCE at the start of a VBScript, so you can remove that from the top of new scripts being appended to an existing one in Notepad.  Each subsequent script below the final "Next" from the previous one just needs to start with the call to the "WMI Class" like this:

Set objWMIService = GetObject .... etc.

I have attached a template where you can insert the scripts generated by Rob van der Woude's "WMIGen.hta".

I have added the date conversion function from the Scriptomatic 2.0 scripts at the bottom in case you want to have dates shown in the normal format rather than as: "20110212160548.951000+000" (= yyyymmddhhmmss.whatever).  To use this function in a "WScript.Echo" line, just do as follows.

Example: Shows the operating system install date using "Win32_OperatingSystem" class:

WScript.Echo "InstallDate: " & objItem.InstallDate

Change it to this:

WScript.Echo "Install Date: " & WMIDateStringToDate(objInstance.InstallDate)

I hope this helps you to easily generate your own scripts whenever you need.

Bill

 
' This VBScript code was generated using the WMI Code Generator, Version 5.10
' http://www.robvanderwoude.com/wmigen.php

' Template for scripts generated by the program.
' Leave the top part of this script as it is.

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly       = &h20

If WScript.Arguments.UnNamed.Count = 1 Then
	strComputer = WScript.Arguments.UnNamed(1)
Else
	strComputer = "."
End If

' Substitute XXXXX_XXXXXXXXXXXXXX for proper WMI Class name.
' PASTE WScript.Echo lines for each WMI Class call where indicated

Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/CIMV2" )
Set colInstances = objWMIService.ExecQuery( "SELECT * FROM XXXXX_XXXXXXXXXXXXXX", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )

For Each objInstance In colInstances
	' Insert WScript.Echo lines here
	WScript.Echo
Next

Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/CIMV2" )
Set colInstances = objWMIService.ExecQuery( "SELECT * FROM XXXXX_XXXXXXXXXXXXXX", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )

For Each objInstance In colInstances
	' Insert WScript.Echo lines here
	WScript.Echo
Next

Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/CIMV2" )
Set colInstances = objWMIService.ExecQuery( "SELECT * FROM XXXXX_XXXXXXXXXXXXXX", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )

For Each objInstance In colInstances
	' Insert WScript.Echo lines here
	WScript.Echo
Next

Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm: 
	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Open in new window

0
 
LVL 4

Accepted Solution

by:
IceCode earned 500 total points
Comment Utility
Alright, here's some love.  This should do everything you asked for and then some.  First, if you double-click the script it will prompt you for a computer name and run one single report on that computer.  It will create a folder where you run this script from called "Computer Info Reports" where it will put the report named after the computer.  You can change the name of this folder in the script on line 15.

Secondly, you can run this script from the command line and pass an argument that is the name of a text file.  For example: "C:\Users\dogbert\Documents\Scripts\Get Computer Info.vbs" computers.txt

The text file must be in the same folder as this script is running from, put one computer name on each line and the script will run through it and generate a report for every single one.  Unreachable computers will still generate a report, with the error information.  I hope you like it, I put a lot of effort into it.  Let me know if you have questions.  Oh, and I am assuming you will be running this with an account that has permissions to all of these computers.
FN = wscript.scriptfullname 'Grabs the full path and name of this script
LenFN = Len(FN) 			'Gets the length of FN
N = wscript.scriptname 		'Gets only the name of this script
LenN = Len(N) 				'Gets the length of N
DiffN = LenFN - LenN - 1  	'Gets the differnce in length between FN and N
PathN = Mid(FN,1,DiffN)  	'Takes the full name and removes DiffN characters

Set sho = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set nwo = CreateObject("WScript.Network")

Const ForReading = 1
Dim objWMIService
Dim oReport
sFolder = "Computer Info Reports"

On Error Resume Next
Set args = WScript.Arguments
sFile = args.Item(0)
Err.Clear

If sFile <> "" Then
	If fso.FileExists(PathN & "\" & sFile) Then
		Set objTextFile = fso.OpenTextFile (PathN & "\" & sFile, ForReading)
			Do Until ObjTextFile.AtEndOfStream
	    		sComputer = objTextFile.ReadLine
	    		createReport sComputer
    		Loop
    		ObjTextFile.Close
    		finish
	End If
End If

sComputer = InputBox("Enter Computer Name:","Computer Name:")
If sComputer = "" Then
	finish
End If

createReport(sComputer)
finish

Function createReport(sComputer)
	If fso.FolderExists(PathN & "\" & sFolder) = False Then
		fso.CreateFolder(PathN & "\" & sFolder)
	End if
	sReport = PathN & "\" & sFolder & "\" & sComputer & ".txt"
	Set oReport = fso.CreateTextFile(sReport)

	On Error Resume Next
	Err.Clear

	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")

	If Err.Number <> 0 Then
		generateErrorData sComputer, Err.Number, Err.Description, Err.Source
	Else
		generateMachineData sComputer
	End If
End Function

Function generateMachineData(sComputer)
	writeHeader(sComputer)
	Set colSettings = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48)
	For Each objSetting in colSettings 
		oReport.WriteLine "  Serial Number: " & objSetting.SerialNumber
	Next
	
	Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
	For Each objComputer in colSettings 
	    oReport.writeline "  System Name: " & objComputer.Name
	    oReport.writeline "  System Manufacturer: " & objComputer.Manufacturer
	    oReport.writeline "  System Model: " & objComputer.Model
	    oReport.WriteLine vbCrLf & vbCrLf
	    oReport.writeline "  Total (Usable) Physical Memory: " & Round(objComputer.TotalPhysicalMemory / 1024 /1024,0) & " MB"
	    oReport.WriteLine "  -------------------------------"
	    sNumProcessors = objComputer.NumberOfProcessors	    
	Next
	
	Set colMemory = objWMIService.ExecQuery ("Select * from Win32_PhysicalMemory")
	slotNum = 0
	For Each objMemory In colMemory
		oReport.WriteLine "     Memory Slot (" & slotNum & ")"
		oReport.WriteLine "     Memory Speed: " & objMemory.Speed & " MHZ"
		oReport.WriteLine "     Capacity: " & Round(objMemory.Capacity /1024 /1024,0) & " MB"
		oReport.WriteLine vbCrLf
		slotNum = slotNum + 1
	Next

	Set colSettings = objWMIService.ExecQuery ("Select * from Win32_Processor")
	oReport.WriteLine vbCrLf
	oReport.writeline "  Number of Processors: " & sNumProcessors
	oReport.WriteLine "  ---------------------"
	For Each objProcessor in colSettings 
	    oReport.writeline "     " & objProcessor.Description
	    oReport.writeline "     Type: " & objProcessor.ProcessorType & ", Architecture: " & objProcessor.Architecture &_
	    ", Maximum Clock Speed: " & objProcessor.MaxClockSpeed
	    oReport.WriteLine vbCrLf
	Next
	
	Set colAdapters = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
	oReport.WriteLine vbCrLf
	oReport.WriteLine "  Network Adapters"
	oReport.WriteLine "  ----------------"
	For Each objAdapter in colAdapters
		oReport.WriteLine "     " & objAdapter.Description
		oReport.writeline "        HostName: " & objAdapter.DNSHostName
		oReport.writeline "        Domain: " & objAdapter.DNSDomain
		oReport.writeline "        Physical (MAC) address: " & objAdapter.MACAddress
	
		If Not IsNull(objAdapter.IPAddress) Then
		  For i = 0 To UBound(objAdapter.IPAddress)
		     oReport.writeline "        IP address: " & objAdapter.IPAddress(i)
		  Next
		End If
		
		If Not IsNull(objAdapter.IPSubnet) Then
		  For i = 0 To UBound(objAdapter.IPSubnet)
		     oReport.writeline "        Subnet: " & objAdapter.IPSubnet(i)
		  Next
		End If
		
		If Not IsNull(objAdapter.DefaultIPGateway) Then
		  For i = 0 To UBound(objAdapter.DefaultIPGateway)
		     oReport.writeline "        Default gateway: " & objAdapter.DefaultIPGateway(i)
		  Next
		End If
   
		If Not IsNull(objAdapter.DNSServerSearchOrder) Then
		  For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
		     oReport.writeline "        DNS Server(" & i & "): " & objAdapter.DNSServerSearchOrder(i)
		  Next
		End If
		
		oReport.writeline "        DHCP Enabled: " & objAdapter.DHCPEnabled
		oReport.writeline "        DHCP Server: " & objAdapter.DHCPServer
		oReport.WriteLine vbcrlf
	Next
	
End Function

Function generateErrorData(sComputer,n,d,s)
	writeHeader(sComputer)
	oReport.WriteLine "  ERROR: Unable to reach WMI on " & sComputer
	oReport.WriteLine vbcrlf
	oReport.WriteLine "  Error Number: " & n
	oReport.WriteLine "  Error Description: " & d
	oReport.WriteLine "  Source: " & s
End Function

Sub writeHeader(sComputer)
	sReportHeader = "Report for: " & sComputer & ", TimeStamp: " & Now()
	oReport.WriteLine sReportHeader
	iDashes = Len(sReportHeader)
	For i = 0 To iDashes
		oReport.Write "-"
	Next
	oReport.WriteLine vbcrlf
End Sub

Sub finish
	WScript.Echo "Done!"
	WScript.Quit
End Sub

Open in new window

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 4

Expert Comment

by:IceCode
Comment Utility
Personally, by the way, I do not like computer generated code very much.  I like to learn by disecting code and by writing my own.  To each his own I guess.
0
 

Author Comment

by:vcampos
Comment Utility
This is awesome Icecode! You have talent! Also, great show of love for this Valentine's day. This script works perfectly. Just as a side note. Do you think it's possible to obtain the monitor information like serial number, manufacture and model with this same script?
0
 

Author Closing Comment

by:vcampos
Comment Utility
Icecode has done fantastic job!
0
 
LVL 4

Expert Comment

by:IceCode
Comment Utility
The monitor information isn't really going to work out, there is a WMI namespace for it (WIN32_DesktopMonitor) but the fields always tend to be blank and inconsistent.  And, the serial number is just plain not available.  Glad you like the script, take care!
0
 

Expert Comment

by:efd1126
Comment Utility
This is great.  Can u provide the same script but with output going to rows on a spreadsheet instead of txt files?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
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 how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now