|
-
Mar 20th, 2008, 06:15 AM
#1
Thread Starter
New Member
looking for help with script to gather and print certain network info
I could be way off on this script and I may not be in the right place to post my question, but here goes. I have been trying to manipulate this script to make it work so there may seem to be some lines that are extra. I have commented out many that I have been experimenting with. I will clean it once I get it to function. This was born out of the need to scan a network that has one domain, but several locations. The goal as to scan the entire domain and gather the workstation information. When I run the script it des not error and I do get a .txt file created as needed. The issue is that the text file is blank. I know I am missing something simple I just cannot see it. I have even tried just running it against my local machine, still no data collected. Any input would be greatly appreciated.
As I sais there are extra lines here and there because I have tried to do it different ways. I commented out the extras.
edit -- I tried to remove the extraneous lines to make the code a little easier to follow.
Code:
Option Explicit
'On Error Resume Next
Dim strComputer
Dim objItem
Dim sOutput
Dim objWMIService
Dim colItems
Dim strOutput
Dim wmiRoot
Dim wmiQuery
Dim colComputers
Dim objComputer
Dim strComputerRole
Const ForWriting = 2
Const OpenAsASCII = 0
Const CreateIfNotExist = True
Dim sDomain
sDomain = InputBox("Enter domain to inventory")
Dim oDomain
Set oDomain = GetObject("WinNT://" & sDomain)
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim strFilePath
strFilePath = "c:\Scripts\report.txt"
Dim oOutput
Set oOutput = oFSO.OpenTextFile(strFilePath ,ForWriting, CreateIfNotExist, OpenAsASCII)
Dim oObject, sComputerName, sDetails
For Each oObject In oDomain
If oObject.Class = "Computer" Then
sComputerName = oObject.Name
sDetails = GetOSInfo(sComputerName)
oOutput.WriteLine sDetails
End If
Next
oOutput.Close
Set oOutput = Nothing
Set oFSO = Nothing
Set oObject = nothing
Set oDomain = Nothing
WScript.Echo "Output saved to c:\Scripts\report.txt"
Function GetOSInfo(strComputer)
wmiRoot = "winmgmts:\\" & strComputer & "\root\cimv2"
wmiQuery = "Select DomainRole from Win32_ComputerSystem"
Set objWMIService = GetObject(wmiRoot)
Set colComputers = objWMIService.ExecQuery (wmiQuery)
'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery( "Select * from Win32_OperatingSystem",,48)
strOutput = String(70,"-")
strOutput = strOutput & strComputer
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
GetOSInfo = sOutput
End Function
Last edited by Solinus; Mar 22nd, 2008 at 07:23 AM.
-
Mar 22nd, 2008, 06:45 AM
#2
Re: looking for help with script to gather and print certain network info
run it in the debugger and you should see if it is actually gathering data. it is early in the morning and i find your file manipulation to be confusing / complicated.
http://msdn2.microsoft.com/en-us/library/hxwfzt61.aspx
-
Mar 24th, 2008, 06:33 AM
#3
Re: looking for help with script to gather and print certain network info
Have you enabled remote wmi on the computers in your network ? See here http://msdn2.microsoft.com/en-us/lib...90(VS.85).aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|