I'm a newbie with this, so please excuse my ignorance in advance
I found this script on the web, but cannot seem to make it work. I keep getting error on line 56 col 7 stating that "remote server machine does not exist", but I dont know enough yet to find the actual error. is it referring to the server I am trying to send the output file to?
line 56 col 7 has:
Set objWMIService = GetObject("winmgmts:\\" & _
sComputer & "\root\cimv2")
here is the entire script:
'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("\\ourserver\public\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 to \\ourserver\public\output.txt"
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,"-") & vbcrlf
strOutput = strOutput & sComputer & vbcrlf
'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 = strOutput
End Function
I found this script on the web, but cannot seem to make it work. I keep getting error on line 56 col 7 stating that "remote server machine does not exist", but I dont know enough yet to find the actual error. is it referring to the server I am trying to send the output file to?
line 56 col 7 has:
Set objWMIService = GetObject("winmgmts:\\" & _
sComputer & "\root\cimv2")
here is the entire script:
'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("\\ourserver\public\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 to \\ourserver\public\output.txt"
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,"-") & vbcrlf
strOutput = strOutput & sComputer & vbcrlf
'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 = strOutput
End Function