Jump to content

a small inventory script


Recommended Posts

I'm not a coder, but would like to get this script running. I found it at informit.com. I get the gist of what's going on, but I keep getting this error.

'get domain name
Dim sDomain
sDomain = InputBox("Enter domain to inventory")

'connect to domain and retrieve
'a list of member objects
Dim oDomain
Set oDomain = GetObject("WinNT://" & sDomain)

'get the filesystemobject
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")

'open an output file
Dim oOutput
Set oOutput = oFSO.CreateTextFile("output.txt")

'run through the objects
Dim oObject, sComputerName, sDetails
For Each oObject In oDomain

'is this object a computer?
If oObject.Class = "Computer" Then

'yes - get computer name
sComputerName = oObject.Name

'get OS info
sDetails = GetOSInfo(sComputerName)

'write info to the file
oOutput.Write sDetails

End If
Next
'close the output file
oOutput.Close

'release objects
Set oOutput = Nothing
Set oFSO = Nothing
Set oObject = nothing
Set oDomain = Nothing

'display completion message
WScript.Echo "Output saved"

Function GetOSInfo(sComputer)

'declare variables
Dim objWMIService
Dim colItems
Dim strOutput

'get WMI service
Set objWMIService = GetObject("winmgmts:\\" & _
sComputer & "\root\cimv2")

'get item collection
Set colItems = objWMIService.ExecQuery( _
"Select * from Win32_OperatingSystem",,48)

'init output string
strOutput = String(70,"-")
strOutput = strOutput & sComputer

'append info to output string
For Each objItem in colItems
strOutput = strOutput & "BuildNumber: " & _
objItem.BuildNumber & vbCrLf
strOutput = strOutput & "BuildType: " & _
objItem.BuildType & vbCrLf
strOutput = strOutput & "Caption: " & _
objItem.Caption & vbCrLf
strOutput = strOutput & "EncryptionLevel: " & _
objItem.EncryptionLevel & vbCrLf
strOutput = strOutput & "InstallDate: " & _
objItem.InstallDate & vbCrLf
strOutput = strOutput & "Manufacturer: " & _
objItem.Manufacturer & vbCrLf
strOutput = strOutput & "MaxNumberOfProcesses: " & _
objItem.MaxNumberOfProcesses & vbCrLf
strOutput = strOutput & "MaxProcessMemorySize: " & _
objItem.MaxProcessMemorySize & vbCrLf
strOutput = strOutput & "Name: " & _
objItem.Name & vbCrLf
strOutput = strOutput & _
"NumberOfLicensedUsers: " & _
objItem.NumberOfLicensedUsers & vbCrLf
strOutput = strOutput & "NumberOfProcesses: " & _
objItem.NumberOfProcesses & vbCrLf
strOutput = strOutput & "NumberOfUsers: " & _
objItem.NumberOfUsers & vbCrLf
strOutput = strOutput & "OSProductSuite: " & _
objItem.OSProductSuite & vbCrLf
strOutput = strOutput & "OSType: " & _
objItem.OSType & vbCrLf
strOutput = strOutput & "OtherTypeDescription: " & _
objItem.OtherTypeDescription & vbCrLf
strOutput = strOutput & "Primary: " & _
objItem.Primary & vbCrLf
strOutput = strOutput & "ProductType: " & _
objItem.ProductType & vbCrLf
strOutput = strOutput & "RegisteredUser: " & _
objItem.RegisteredUser & vbCrLf
strOutput = strOutput & "SerialNumber: " & _
objItem.SerialNumber & vbCrLf
strOutput = strOutput & _
"ServicePackMajorVersion: " & _
objItem.ServicePackMajorVersion & vbCrLf
strOutput = strOutput & _
"ServicePackMinorVersion: " & _
objItem.ServicePackMinorVersion & vbCrLf
strOutput = strOutput & "Version: " & _
objItem.Version & vbCrLf
strOutput = strOutput & "WindowsDirectory: " & _
objItem.WindowsDirectory & vbCrLf
Next

'return results
GetOSInfo = sOutput

End Function

The error screen says to check line 56, which I do, but I don't get what's wrong.

Please help. Thanks.

post-29225-1156269328_thumb.jpg

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...