• RSS
  • Twitter
  • FaceBook

Welcome to ISAserver.org

Forums | Register | Login | My Profile | Inbox | RSS RSS icon | My Subscription | My Forums | Address Book | Member List | Search | FAQ | Ticket List | Log Out

VBS script to disable rule

Users viewing this topic: none

Logged in as: Guest
  Printable Version
All Forums >> [ISA 2006 Misc.] >> ISA 2006 Programming >> VBS script to disable rule Page: [1]
Login
Message << Older Topic   Newer Topic >>
VBS script to disable rule - 11.May2009 10:28:21 AM   
HCS

 

Posts: 2
Joined: 11.May2009
Status: offline
I am probally missing something very obvious here! I am trying to use the script below which i download form http://www.isascripts.org/

I am tying to get it to disable a rule called "test". I have edited the script changing the feilds, however it does not run?

If anyone can shed any light on what i might be doing wrong. I am running ISA 2006 if that effects anything.

If WScript.Arguments.Count <> 2 Then Call ShowHelpAndQuit()
sRuleName = WScript.Arguments.Item(0)
sAction   = WScript.Arguments.Item(1)
If (LCase(sRuleName) = "/?") Or (LCase(sRuleName) = "/h") Or (LCase(sRuleName) = "-h") Then Call ShowHelpAndQuit()


If EnableOrDisableRule(sRuleName, sAction) Then
   WScript.Echo vbCrLf & "Success! " & UCase(sRuleName) & " = " & UCase(sAction) & "D"
Else
   WScript.Echo vbCrLf & "ERROR: " & Err.Number & " " & Err.Description
End If






'*************************************************************************************
' Functions() & Procedures()
'*************************************************************************************


'
' sRuleName is the name of the rule, in doublequotes if it contains spaces.
' sAction is either "enable" or "disable" (or just "e" and "d").
'
' Function returns true if either it is successful or if sRuleName Is
' already set to sAction specified.
'
Function EnableOrDisableRule(sRuleName, sAction)
   On Error Resume Next
   If Not IsObject(oFPC) Then Set oFPC = CreateObject("FPC.Root")
   Set oPolicyRule = oFPC.GetContainingArray.ArrayPolicy.PolicyRules.Item(sRuleName)
   'If Err.Number = -2147024894 Then WScript.Echo "Cannot find the rule named " & sRuleName
   If Err.Number <> 0 Then EnableOrDisableRule = False : Exit Function
   If Left(LCase(sAction),1) = "e" Then bState = True Else bState = False
   If oPolicyRule.Enabled = bState Then EnableOrDisableRule = True : Exit Function
   oPolicyRule.Enabled = bState
   oPolicyRule.Save
   If Err.Number = 0 Then EnableOrDisableRule = True Else EnableOrDisableRule = False
   'If Err.Number <> 0 Then WScript.Echo "Problem changing rule state."
   On Error Goto 0
End Function



Sub ShowHelpAndQuit()
   Dim sUsage : sUsage = vbCrLf
   sUsage = sUsage & vbCrLf
   sUsage = sUsage & "ISA_Enable-Disable_Rule.vbs rulename action" & vbCrLf
   sUsage = sUsage & vbCrLf
   sUsage = sUsage & "Purpose: Enables or disables a rule, not including System Policy rules." & vbCrLf
   sUsage = sUsage & vbCrLf
   sUsage = sUsage & "   Args: rulename = test" & vbCrLf
   sUsage = sUsage & "         action   = disable" & vbCrLf
   sUsage = sUsage & vbCrLf
   sUsage = sUsage & "  Legal: SCRIPT PROVIDED ""AS IS"" WITHOUT WARRANTIES OR GUARANTEES OF ANY" & vbCrLf
   sUsage = sUsage & "         KIND. USE AT YOUR OWN RISK. Public domain, no rights reserved." & vbCrLf
   sUsage = sUsage & "         ( www.ISAscripts.org )" & vbCrLf
   sUsage = sUsage & vbCrLf
   WScript.Echo sUsage
   WScript.Quit
End Sub


'EOF*******************************************************************************
Post #: 1
RE: VBS script to disable rule - 13.May2009 8:45:22 PM   
fixitchris

 

Posts: 148
Joined: 23.May2007
Status: offline
Download the ISA Rules Admin from http://sync-io.net/go/www/Products/ISATools.aspx.  Look through the code.

(in reply to HCS)
Post #: 2

Page:   [1] << Older Topic    Newer Topic >>
All Forums >> [ISA 2006 Misc.] >> ISA 2006 Programming >> VBS script to disable rule Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts