2 Replies Latest reply on Nov 14, 2019 2:07 PM by xtraspecialj

    Alert Action Updating via the API


      Hi, I only found one other post about this, but I'm still not sure how to do this exactly. 


      I'm trying to write a PowerShell script that will bulk Enable/Disable Alert Actions.  I see there is an UpdateAction verb and an UpdateActionProperties verb for the Orion.Actions entity, but I'm not sure how to use them to just enable/disable an action.  The one post I found about this shows him putting in a bunch of XML including all of the Alert Actions properties.  Do I need to provide the full XML, or is there just a way to send Enable/Disable to it without having to populate the full XML?  My guess is I'll need the knowledge of tdanner or dan jagnow to answer this.

        • Re: Alert Action Updating via the API
          dan jagnow

          Happily, you don't have to provide the full XML.  You can just update the Enabled property like the script below.  This example is for updating a single action, but you could adapt it to handle multiple actions for a bulk update.


          Import-Module SwisPowerShell

          # Connect to SWIS.

          $hostname = "myserver"

          $username = "muser"

          $password = "superSecretPassword"

          $swis = Connect-Swis -host $hostname -Username $Username -Password $Password

          # Get the URI of an action associated with an alert configuration.

          # Tweak this query to find the alert action you care about.

          $alertName = "Alert me when an application goes down"

          $actionTypeID = "Email"

          $query = "SELECT TOP 1 a.Uri

              FROM Orion.AlertConfigurations ac

              INNER JOIN Orion.ActionsAssignments aa ON ac.AlertID = aa.ParentID

              INNER JOIN Orion.Actions a ON aa.ActionAssignmentID = a.ActionID

              WHERE ac.Name = @alertName AND a.ActionTypeID = @actionTypeID"

          $actionUri = Get-SwisData -SwisConnection $swis -Query $query -Parameters @{alertName = $alertName; actionTypeID = $actionTypeID}

          # Do this...

          # Disable the alert action.

          $enabledProps = @{

              Enabled = $false;


          Set-SwisObject -SwisConnection $swis -Uri $actionUri -Properties $enabledProps | Out-Null

          # ... Or do this...

          # Enable the alert action.

          $enabledProps = @{

              Enabled = $true;


          Set-SwisObject -SwisConnection $swis -Uri $actionUri -Properties $enabledProps | Out-Null

          1 of 1 people found this helpful