Ying Li at myITforum.com

PowerShell & System Center

VB Script to check on McAfee EPO Exclusions

Here is a VB script to check and verify the McAfee On Access Scan Exclusions on multiple machines and write the results to txt files.

I am doing VB script because my current job(production) environment don’t have PowerShell installed yet. But I have to say this is not a very pleasant experience after I already used to the PowerShell way of thinking. Just look at how “complicated” to write the output to a txt file in VB script, In PowerShell I could accomplish the same task in a line or two.

'On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002
Const ForWriting = 2
const ForAppending = 8
Const OpenAsASCII = 0
Const CreateIfNotExist = True

'Read machine names from a txt file

Set ObjFso = CreateObject("Scripting.FileSystemObject")
Set InputFile = Objfso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine

GetRegInfo

Loop

'*********************************************************************************************************
'Get information from Registry

Sub GetRegInfo

Set oReg=GetObject( _
   "winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Network Associates\TVD\shared Components\On Access Scanner\McShield\Configuration\"

‘Enumerate the SubKeys here

oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
 
For Each subkey In arrSubKeys

    strKeyPath = "SOFTWARE\Network Associates\TVD\shared Components\On Access Scanner\McShield\Configuration\" & subkey
    Exclusions = strKeyPath & VBcrlf

‘Enumerate the Keys and identify the ExcludedItem_* key and get it’s value and put them in Exclusions variable

oReg.EnumValues HKEY_LOCAL_MACHINE, strkeyPath, arrValuenames

For i=0 To UBound(arrValueNames)

if Left(arrValueNames(i), 12) = "ExcludedItem" Then

oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,arrValueNames(i),strValue
 
Exclusions = Exclusions & (right(strValue,(Len(strValue)-5))) & VBcrlf

End If

Next

'wscript.Echo Exclusions

strFilePath = "c:\Temp\" & strcomputer & ".txt"

' Open the file for write access.
Set objFile = objFSO.OpenTextFile(strFilePath, _
    ForAppending,CreateIfNotExist, OpenAsASCII)
' Write to file.

objFile.WriteLine Exclusions
objFile.Close

Next

End Sub

Posted: Nov 07 2007, 07:28 PM by yli628 | with no comments
Filed under: ,

Comments

No Comments