Use the SDK to Disable a Port through UDT as an Alert Action

Version 5

    I've been tinkering around with the SDK lately, and with the new feature in UDT allowing users to disable ports from the Orion Web console, I came up with a nifty way to disable a port as an alert trigger action. You'll have to be familiar with executing VB scripts as alert trigger actions, as well as PoSH, and the SDK. I also urge caution when implementing something as potentially impactful as this as an automated action. It is a surprisingly simple process.

     

    In the alert, I'm passing the NodeID and PortID to be handled by the script:

     

    Here is the VB:

     

        intNodeID = WScript.Arguments(0)

        intPortID = WScript.Arguments(1)

     

        Set objShell = CreateObject("Wscript.shell")

     

        objShell.run("powershell -file c:\a_PoSH\AdminShut.ps1 -nodeid " & intNodeID & " -portids " & intPortID & "")

     

     

    This calls the PoSH script, and in turn uses the SDK to disable the port:

     

        param($nodeid,[int[]] $portids)

     

        if (! (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {

            Add-PSSnapin "SwisSnapin"

        }

     

        #Connect to Swis

        $swis = Connect-Swis -v2 -Trusted #-Hostname 'localhost'

     

        Invoke-SwisVerb $swis Orion.UDT.Port AdministrativeShutdown @($nodeid,[int[]] $portids)

     

    To enable, simply reverse the process:

     

    VB:

     

        intNodeID = WScript.Arguments(0)

        intPortID = WScript.Arguments(1)

     

        Set objShell = CreateObject("Wscript.shell")

     

        objShell.run("powershell -file c:\a_PoSH\AdminEnable.ps1 -nodeid " & intNodeID & " -portids " & intPortID & "")

     

    PoSH:

     

        param($nodeid,[int[]] $portids)

     

        if (! (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {

            Add-PSSnapin "SwisSnapin"

        }

     

        #Connect to Swis

        $swis = Connect-Swis -v2 -Trusted #-Hostname 'localhost'

     

        Invoke-SwisVerb $swis Orion.UDT.Port AdministrativeEnable @($nodeid,[int[]] $portids)




    Enjoy!


    --Andrew

    www.Loop1Systems.com