Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inventory machine hardware, etc.. 11

Status
Not open for further replies.

bmquiroz

IS-IT--Management
Sep 26, 2003
207
0
0
US
I need to inventory several workstations and servers and need a script to automate this process. I know this could be accomplished using WMI so if any one has code that they can pass on, I would appreciate it. I basically need a script that will enumerate drives, shares, get memory size, CPU speed, OS version and SP, etc..

Thanks!
 
Oh, who do you love? if this isn't worth a star I don't know what is.

This script does the inventory then saves it to a text file with the name of the PC.

'==========================================================================
'
' NAME: <MemProcDiskInventory.vbs>
'
' AUTHOR: Mark D. MacLachlan , ITSynergy
' DATE : 5/15/2003
'
' COMMENT: <Inventories computer configuration and writes report to disk>
'==========================================================================
on error resume Next

Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")


report = strComputer & " Computer Inventory" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "OS Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objItem in colItems
report = report & strComputer & vbCrLf & "OS Details"& vbCrlf
report = report & "Caption: " & objItem.Caption & vbCrLf
report = report & "Description: " & objItem.Description & vbCrLf
report = report & "EncryptionLevel: " & objItem.EncryptionLevel & vbCrLf
report = report & "InstallDate: " & objItem.InstallDate & vbCrLf
report = report & "Manufacturer: " & objItem.Manufacturer & vbCrLf
report = report & "MaxNumberOfProcesses: " & objItem.MaxNumberOfProcesses & vbCrLf
report = report & "Name: " & objItem.Name & vbCrLf
report = report & "Organization: " & objItem.Organization & vbCrLf
report = report & "OSProductSuite: " & objItem.OSProductSuite & vbCrLf
report = report & "RegisteredUser: " & objItem.RegisteredUser & vbCrLf
report = report & "SerialNumber: " & objItem.SerialNumber & vbCrLf
report = report & "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion & vbCrLf
report = report & "ServicePackMinorVersion: " & objItem.ServicePackMinorVersion & vbCrLf
report = report & "Version: " & objItem.Version & vbCrLf
report = report & "WindowsDirectory: " & objItem.WindowsDirectory & vbCrLf
Next

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Memory and Processor Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objComputer in colSettings
'report = report & objComputer.Name & vbcrlf
report = report & objComputer.TotalPhysicalMemory /1024\1024+1 & "MB Total memory" & vbcrlf
Next
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_Processor")
For Each objProcessor in colSettings
report = report & objProcessor.Description & " Processor" & vbCrLf
Next

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Disk Drive Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf

Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
report = report & objLogicalDisk.FreeSpace /1024\1024+1 & "MB Free Disk Space" & vbCrLf
report = report & objLogicalDisk.Size /1024\1024+1 & "MB Total Disk Space" & vbCrLf

oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
software = vbCrLf & "******************************************" & vbCrLf
software = software & vbCrLf & "Installed Software" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each subkey In arrSubKeys
'MsgBox subkey
If Left (subkey, 1) <> "{" Then
software = software & subkey & vbCrLf
End If
Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)
ts.write report
ts.write software
'MsgBox Report
MsgBox "Done"

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Wow great script! and yes it certainly deserves a star. I hope you don't mind but I've added a code snippet to your script, this will retrieve service information.
 
SNIPIN, thanks for sharing.
Can you please post your added code snippet ?
 
not sure whether to start a new thread or not since mine is also inventory related. On a much simpler scale at the moment though.

The problem I have is that at the moment, I am just retrieving Serial #s. The following code works fine. The only hitch is that when it encounters an IP address that is not currently turned on, or is not a PC (i.e. printer, Mac, etc) it fills in the serial # for the previous entry (ies) until it finds a new one to enter. How do I modify to at least leave the line blank if it is not a PC?


On Error Resume next
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\test\divtest.txt", ForReading)

Do Until objTextFile.AtEndOfStream
StrComputer = objTextFile.Readline
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery _
("Select * from Win32_BIOS")
For each objBIOS in colBIOS
Wscript.Echo strComputer & vbTab & vbTab & "Serial Number: " & objBIOS.SerialNumber
Err.clear
Next
Loop

I run the script at the command prompt with the followin line

c:\cscript inv.vbs >serials.log

the results come back as (IPs have been modified)

x.y.z.244 Serial Number: 6X1ADYSZ51EE
x.y.z.134 Serial Number: 7MJC121
x.y.z.187 Serial Number: 1HLM521
x.y.z.195 Serial Number: C6R7521
x.y.z.51 Serial Number: C6R7521
x.y.z.164 Serial Number: C6R7521
x.y.z.38 Serial Number: 6X25JYHZZ04A
x.y.z.104 Serial Number: 6X25JYHZZ04A
x.y.z.214 Serial Number: 6124DYSZB649
x.y.z.203 Serial Number: 6X23JYFZX0AC



Suggestions?
 
Try to amen your script with something like this:
Set colBIOS = objWMIService.ExecQuery _
("Select * from Win32_BIOS")
If Err.Number = 0 Then
For each objBIOS in colBIOS
Wscript.Echo strComputer & vbTab & vbTab & "Serial Number: " & objBIOS.SerialNumber
Next
Else
Wscript.Echo strComputer
Err.clear
End If

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Sipin, add away and enjoy.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Sorry for the late reply but here is the script:

On Error Resume Next

Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")


report = strComputer & " Computer Inventory" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "OS Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objItem in colItems
report = report & "Caption: " & objItem.Caption & vbCrLf
report = report & "Description: " & objItem.Description & vbCrLf
report = report & "EncryptionLevel: " & objItem.EncryptionLevel & vbCrLf
report = report & "InstallDate: " & objItem.InstallDate & vbCrLf
report = report & "Manufacturer: " & objItem.Manufacturer & vbCrLf
report = report & "MaxNumberOfProcesses: " & objItem.MaxNumberOfProcesses & vbCrLf
report = report & "Name: " & objItem.Name & vbCrLf
report = report & "Organization: " & objItem.Organization & vbCrLf
report = report & "OSProductSuite: " & objItem.OSProductSuite & vbCrLf
report = report & "RegisteredUser: " & objItem.RegisteredUser & vbCrLf
report = report & "SerialNumber: " & objItem.SerialNumber & vbCrLf
report = report & "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion
report = report & "ServicePackMinorVersion: " & objItem.ServicePackMinorVersion & vbCrLf
report = report & "Version: " & objItem.Version & vbCrLf
report = report & "WindowsDirectory: " & objItem.WindowsDirectory & vbCrLf
Next

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Memory and Processor Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objComputer in colSettings
'report = report & objComputer.Name & vbcrlf
report = report & objComputer.TotalPhysicalMemory /1024\1024+1 & "MB Total memory" & vbcrlf
Next
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_Processor")
For Each objProcessor in colSettings
report = report & objProcessor.Description & " Processor" & vbCrLf
Next

Set cInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" &_
strComputer & "/root/cimv2:Win32_Service").Instances_
'********************************
'*** Enumerate instances in the loop, for each, list relevant properties
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Services" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each oInstance In cInstances
report = report & "Name:" & vbTab & vbTab & oInstance.Properties_("Name").Value & vbCrLf
report = report & "DisplayName:" & vbTab & oInstance.Properties_("DisplayName").Value & vbCrLf
report = report & "StartMode:" & vbTab & oInstance.Properties_("StartMode").Value & vbCrLf
report = report & "State:" & vbTab & vbTab & oInstance.Properties_("State").Value & vbCrLf
Next

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Disk Drive Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf

Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
report = report & objLogicalDisk.FreeSpace /1024\1024+1 & "MB Free Disk Space" & vbCrLf
report = report & objLogicalDisk.Size /1024\1024+1 & "MB Total Disk Space" & vbCrLf

oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
software = software & vbCrLf & "******************************************" & vbCrLf
software = software & "Installed Software" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each subkey In arrSubKeys
'MsgBox subkey
If Left (subkey, 1) <> "{" Then
software = software & subkey & vbCrLf
End If
Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)
ts.write report
ts.write software
'MsgBox Report
MsgBox "Done"
 
Markdmac brilliant script to start with and Sipin nice addition! I am new to VBscript and the whole WMI thing when I have tried this script out it only runs locally, where do you change the text to make it run on another machine? I figured it was something to do with the strComputer variable.
 
Hi Teckiejon,

You are correct in your assumption. The script can be run as a login script and will grab the computername at login.

If you want to feed it a list of computer names, that can be done easily enough. Take a look in the FAQs section of this forum. I have a sample on how to make scripts ready for the enterprise that explains the process.



I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Brilliant! Your FAQ has now pushed the boundaries of WMI scripting to another level for me with the help of my newly created wslist text files full of DNS names and IP addresses. Couldn't work out how to give the FAQ a star so have given this post one!
 
Hi Teckiejon,

Thanks for the star. If you could, please revisit the FAQ and take a look at the very bottom of the screen. There you can rate the FAQ on a scale of 1-10. Would appreciate your leaving feedback there since it has yet to be given a rating.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hi,

Thanks for that script! That is fantastic and although I only work in a small firm really useful!!!! After reasearch some more I found something very useful to dell users. A section that also records the service tag in the file. The code is below...

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

Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
report = report & "DellserviceTag: " & objSMBIOS.SerialNumber & vbCrLf

 
Stu1979,

Great addition. I do a lot with Dell hardware so that is helpful. Here is how I have added it to my script. Using this code it will only display the Dell Service Tag label if it detects that there is data there.

Code:
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
	If objSMBIOS.SerialNumber <> "" Then
    	report = report &  "Dell Service Tag: "  & objSMBIOS.SerialNumber & vbCrLf
    End If
Next


I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hello...I was hoping that you could help me make one small change to your code Markdmac? I want to have a text file that I enter in the patch number (ex. q811931) and compare what is actually on the computer with what is in the text file. I've tried adding the code but I've got brain freeze and cannot dig myself out. Any help is greatly appreciated.

Thanks in advance!

'==========================================================================
'
' NAME: <MemProcDiskInventory.vbs>
'
' AUTHOR: Mark D. MacLachlan , ITSynergy
' DATE : 5/15/2003
'
' COMMENT: <Inventories computer configuration and writes report to disk>
'==========================================================================
on error resume Next

Const ForReading = 1
Dim arrText()
Dim iUpperBound

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso_OpenTextFile("hotfix.txt", ForReading)

iUpperBound = 0
While Not ts.AtEndOfStream
ReDim Preserve arrText(iUpperBound)
arrText(UBound(arrText)) = ts.ReadLine
iUpperBound = iUpperBound + 1
Wend

Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")


report = strComputer & " Computer Inventory" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "OS Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objItem in colItems
report = report & strComputer & vbCrLf & "OS Details"& vbCrlf
report = report & "Caption: " & objItem.Caption & vbCrLf
report = report & "Description: " & objItem.Description & vbCrLf
report = report & "EncryptionLevel: " & objItem.EncryptionLevel & vbCrLf
report = report & "InstallDate: " & objItem.InstallDate & vbCrLf
report = report & "Manufacturer: " & objItem.Manufacturer & vbCrLf
report = report & "MaxNumberOfProcesses: " & objItem.MaxNumberOfProcesses & vbCrLf
report = report & "Name: " & objItem.Name & vbCrLf
report = report & "Organization: " & objItem.Organization & vbCrLf
report = report & "OSProductSuite: " & objItem.OSProductSuite & vbCrLf
report = report & "RegisteredUser: " & objItem.RegisteredUser & vbCrLf
report = report & "SerialNumber: " & objItem.SerialNumber & vbCrLf
report = report & "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion & vbCrLf
report = report & "ServicePackMinorVersion: " & objItem.ServicePackMinorVersion & vbCrLf
report = report & "Version: " & objItem.Version & vbCrLf
report = report & "WindowsDirectory: " & objItem.WindowsDirectory & vbCrLf
Next

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Memory and Processor Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objComputer in colSettings
'report = report & objComputer.Name & vbcrlf
report = report & objComputer.TotalPhysicalMemory /1024\1024+1 & "MB Total memory" & vbcrlf
Next
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_Processor")
For Each objProcessor in colSettings
report = report & objProcessor.Description & " Processor" & vbCrLf
Next

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Disk Drive Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf

Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
report = report & objLogicalDisk.FreeSpace /1024\1024+1 & "MB Free Disk Space" & vbCrLf
report = report & objLogicalDisk.Size /1024\1024+1 & "MB Total Disk Space" & vbCrLf

oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
software = vbCrLf & "******************************************" & vbCrLf
software = software & vbCrLf & "Installed Software" & vbCrLf & "******************************************" & vbCrLf & VbCrLf

For Each key In arrText
For Each subkey In arrSubKeys
If key = subkey Then
If Left (subkey, 1) <> "{" Then
software = software & key & " IS installed!" & VbCrLf
End If
Elseif key <> subkey Then
If Left (subkey, 1) = "{" Then
software = software & key & " IS NOT installed!" & VbCrLf
End If
End If
Next
Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)
ts.write report
ts.write software
'MsgBox Report
'MsgBox "Done"

ts.Close
WScript.Quit
 
Here is a snippet from my latest version of the above script that is available in my Admin Script Pack.

Code:
oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
software = vbCrLf & "******************************************" & vbCrLf
software = software & "Installed Hotfixes" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each subkey In arrSubKeys
'MsgBox subkey
If Lcase(Left(subkey, 2)) = "kb" Then
	software = software & subkey & vbCrLf
End If
Next

Should be easy enough for you to search for the value you are looking for such as:

Code:
If subkey = "kb12345" Then
	kbfound = "Installed"
End If

I hope you find this post helpful.

Regards,

Mark
 
I also want to point out that the reporting features in both WSUS and MBSA can give you a report for all your machines. So the script method may not be the best course of action if you are just looking for a single value.

I hope you find this post helpful.

Regards,

Mark
 
Ahh....great....thank you. Here is an updated version of your script. I'm comparing a txt file against what is on the machine and only displaying the name and if it is installed or not installed. My problem is that some of them have a -xxxxx.xxxx.xxx after them such as KB929221-33883.333.29299 and I need to only look at the actual KB929221 piece. I hope that makes sense and I appreciate your help.

Your Script:

'==========================================================================
'
' NAME: <MemProcDiskInventory.vbs>
'
' AUTHOR: Mark D. MacLachlan , ITSynergy
' DATE : 5/15/2003
'
' COMMENT: <Inventories computer configuration and writes report to disk>
'==========================================================================

on error resume Next

Const ForReading = 1
Dim arrText()
Dim iUpperBound
Dim filename
Dim newfilename

Set fso = CreateObject("Scripting.FileSystemObject")

Set ts = fso_OpenTextFile("MSPatches.txt", ForReading)

iUpperBound = 0
While Not ts.AtEndOfStream
ReDim Preserve arrText(iUpperBound)
arrText(UBound(arrText)) = ts.ReadLine
iUpperBound = iUpperBound + 1
Wend

Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")


report = strComputer & " Computer Inventory" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "OS Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objItem in colItems
report = report & strComputer & vbCrLf & "OS Details"& vbCrlf
report = report & "Caption: " & objItem.Caption & vbCrLf
report = report & "Description: " & objItem.Description & vbCrLf
report = report & "EncryptionLevel: " & objItem.EncryptionLevel & vbCrLf
report = report & "InstallDate: " & objItem.InstallDate & vbCrLf
report = report & "Manufacturer: " & objItem.Manufacturer & vbCrLf
report = report & "MaxNumberOfProcesses: " & objItem.MaxNumberOfProcesses & vbCrLf
report = report & "Name: " & objItem.Name & vbCrLf
report = report & "Organization: " & objItem.Organization & vbCrLf
report = report & "OSProductSuite: " & objItem.OSProductSuite & vbCrLf
report = report & "RegisteredUser: " & objItem.RegisteredUser & vbCrLf
report = report & "SerialNumber: " & objItem.SerialNumber & vbCrLf
report = report & "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion & vbCrLf
report = report & "ServicePackMinorVersion: " & objItem.ServicePackMinorVersion & vbCrLf
report = report & "Version: " & objItem.Version & vbCrLf
report = report & "WindowsDirectory: " & objItem.WindowsDirectory & vbCrLf
Next

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Memory and Processor Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objComputer in colSettings
'report = report & objComputer.Name & vbcrlf
report = report & objComputer.TotalPhysicalMemory /1024\1024+1 & "MB Total memory" & vbcrlf
Next
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_Processor")
For Each objProcessor in colSettings
report = report & objProcessor.Description & " Processor" & vbCrLf
Next

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Disk Drive Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf

Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
report = report & objLogicalDisk.FreeSpace /1024\1024+1 & "MB Free Disk Space" & vbCrLf
report = report & objLogicalDisk.Size /1024\1024+1 & "MB Total Disk Space" & vbCrLf

oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
software = vbCrLf & "******************************************" & vbCrLf
software = software & vbCrLf & "Microsoft Patches Summary" & vbCrLf & "******************************************" & vbCrLf & VbCrLf

tst = Chr(1) & Join(arrSubKeys, Chr(1)) & Chr(1)

For i = 0 To UBound(arrText)
If InStr(1, tst, Chr(1) & arrText(i) & Chr(1), 1) > 0 Then
software = software & arrText(i) & " IS installed!" & VbCrLf
Else
software = software & arrText(i) & " IS NOT installed!" & VbCrLf
End If
Next

Set fso = CreateObject("Scripting.FileSystemObject")
filename = strcomputer & ".txt"
newfilename = strcomputer & "_BEFORE.txt"
If fso.fileExists(filename) Then
Set ts = fso.movefile (filename, newfilename)
Else
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)
End If
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)
ts.write report
ts.write software
ts.Close
WScript.Quit


'------------------
The MSPatches.txt file that it compares to.
'------------------
KB896424
KB904706
KB902400
KB896688
KB900725
KB907245
KB905749
KB899589
KB905414
KB905495
KB897715
 
Oh...one more thing. How could I make this script able to run from my WinXP machine against a list of servers? I can't figure out how to do credentials.

Thanks again,

Ace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top