JustScriptIt
Technical User
I have created the following script to troubleshoot issue on our network:
The input file of IP addresses are exactly the same.
The script reads data from WMI, and registry key values.
When I run it on our computer Domain, it outputs one set of data. When I run it on a computer connected to a WORKGROUP, it outputs one set of data.
Why does this happen? How can I get the script to output consistent data, regardless of which Domain/WORKGROUP I am logged into.
For instance, the computer name of the IP address differs, and so does the free disk space on C:, etc, etc.
HELP!!!
Code:
Option Explicit
Dim objInputFSO, objOutputFSO, objFile
Dim strInputFile, strData, arrLines, strLine
Dim objWMISvc, colItems, objItem, strComputerDomain, strMember
Dim strComputer, strKeyPath, strValueName, oReg, strValue, dwValue
Dim objLogicalDisk, strCfree, strDfree, strHDfree
Dim strName, strVersion, intComm, strGroup, strPolicy, strHardware, strVirus, strIPS, intNTP
const ForAppending = 8
const strOutputFile = "output_for_sep_statistics.csv"
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
'Create an Input File System Object
Set objInputFSO = CreateObject("Scripting.FileSystemObject")
'Name of the input text file
strInputFile = InputBox("What is the name of file with list of computers?")
'Open the text file - strData now contains the whole file
strData = objInputFSO.OpenTextFile(strInputFile,1).ReadAll
'Split the text file into lines
arrLines = Split(strData,vbCrLf)
'Create an Output File System Object
Set objOutputFSO = CreateObject("Scripting.FileSystemObject")
'Create Output File
Set objFile = objOutputFSO.CreateTextFile(strOutputFile)
objFile.WriteLine("IP Address, Computer Name, Free Space on C,Free Space on D,Free Space on Hard Drive," & _
"Membership, Current SEP Version,0=Offline 1=Online,Group," & _
"Policy Serial Number,Hardware ID,Virus Definition,IPS Signature,0=NTP Off 1=NTP On")
On Error Resume Next
'Step through the lines
For Each strLine in arrLines
strComputer = strLine
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
Set objWMISvc = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objLogicalDisk = objWMISvc.Get("Win32_LogicalDisk.DeviceID='C:'")
strCfree = Int(objLogicalDisk.FreeSpace / 1048576) & " MB"
Set objLogicalDisk = objWMISvc.Get("Win32_LogicalDisk.DeviceID='D:'")
strDfree = Int(objLogicalDisk.FreeSpace / 1048576) & " MB"
Set objLogicalDisk = objWMISvc.Get("Win32_LogicalDisk.DriveType=3")
strHDfree = Int(objLogicalDisk.FreeSpace / 1048576) & " MB"
Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", ,48 )
For Each objItem in colItems
strComputerDomain = objItem.Domain
strName = objItem.Caption
If objItem.PartOfDomain Then
strMember = "Computer Domain: " & strComputerDomain
Else
strMember = "Workgroup: " & strComputerDomain
End If
Next
strKeyPath = "SOFTWARE\Symantec\Symantec Endpoint Protection\SMC"
strValueName = "ProductVersion"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strVersion = strValue
strKeyPath = "SOFTWARE\Symantec\Symantec Endpoint Protection\SMC\SYLINK\SyLink"
strValueName = "PolicyMode"
oReg.GetDWORDValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
intComm = dwValue
strKeyPath = "SOFTWARE\Symantec\Symantec Endpoint Protection\SMC\SYLINK\SyLink"
strValueName = "CurrentGroup"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strGroup = strValue
strKeyPath = "SOFTWARE\Symantec\Symantec Endpoint Protection\SMC\SYLINK\SyLink"
strValueName = "SerialNumber"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strPolicy = strValue
strKeyPath = "SOFTWARE\Symantec\Symantec Endpoint Protection\SMC\SYLINK\SyLink"
strValueName = "HardwareID"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strHardware = strValue
strKeyPath = "SOFTWARE\Symantec\SharedDefs"
strValueName = "DEFWATCH_10"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strVirus = strValue
strKeyPath = "SOFTWARE\Symantec\SharedDefs\SymcData-cndcipsdefs"
strValueName = "cndcIps"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strIPS = strValue
strKeyPath = "SOFTWARE\Symantec\Symantec Endpoint Protection\SMC"
strValueName = "smc_engine_status"
oReg.GetDWORDValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
intNTP = dwValue
objFile.WriteLine(strComputer & "," & strName & "," & strCfree & "," & strDfree & "," & strHDfree & "," & _
strMember & "," & strVersion & "," & intComm & "," & strGroup & _
"," & strPolicy & "," & strHardware & "," & strVirus & "," & strIPS & "," & intNTP)
Next
Wscript.echo "Output is located at output_for_sep_statistics.csv"
'Cleanup
Set objInputFSO=Nothing
Set objOutputFSO=Nothing
The input file of IP addresses are exactly the same.
The script reads data from WMI, and registry key values.
When I run it on our computer Domain, it outputs one set of data. When I run it on a computer connected to a WORKGROUP, it outputs one set of data.
Why does this happen? How can I get the script to output consistent data, regardless of which Domain/WORKGROUP I am logged into.
For instance, the computer name of the IP address differs, and so does the free disk space on C:, etc, etc.
HELP!!!