This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Verb Orion.AlertConfigurations.Export not working

This script was working and just stopped working with 2019.4. 

Any ideas  ?

I saw a similar posting (https://thwack.solarwinds.com/t5/Discussions/ClearAlert-Verb-in-Orion-AlertActive-Entity/td-p/340633) but that did not resolve it.

The problem verb is: Orion.AlertConfigurations Export.    The $AlertID worked fine previously, but no longer works.

The error I'm getting is:

Invoke-SwisVerb : Verb Orion.AlertConfigurations.Export cannot unpackage parameter 0 of type System.Int32
At line:18 char:32
+ ... dAlertsrc=Invoke-SwisVerb $swissrc Orion.AlertConfigurations Export ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

This is the code:
Add-PSSnapin swissnapin

$swissrc=Connect-Swis -Hostname x.x.x.x -u "cscoengineer" -p "xxxx"
$swisdst = Connect-Swis -Hostname x.x.x.x -u "cscoengineer" -p "xxxx"
$AlertIDssrc=Get-SwisData -SwisConnection $swissrc -Query "select Name, AlertID from Orion.AlertConfigurations where enabled=1"
foreach ($AlertID in $AlertIDsSRC) {
        $AlertIDDST = Get-SwisData -SwisConnection $swisdst -Query "select Name from Orion.AlertConfigurations where name='$($AlertID.Name)'"
        #Write-Output "SRC:$($AlertID.Name)        DST:$($AlertIDDST.Name)    XXX:$AlertIDDST"
        if ($AlertIDDst -eq $null) {
           Write-Output "Alert not in DST. Migrating Alert:$($AlertID.Name)"
           $ExportedAlertsrc=Invoke-SwisVerb $swissrc Orion.AlertConfigurations Export $AlertID
           #Invoke-SwisVerb $swisdst Orion.AlertConfigurations Import $ExportedAlertSRC
           }
           else
           {Write-Output "Alert in DST. Skipping: $($AlertID.Name)" }
}
 
  • After reading the docs, I got it to work

    Add-PSSnapin swissnapin

    $swissrc=Connect-Swis -Hostname 192.168.25.30 -u "cscoengineer" -p "xxx"
    $swisdst = Connect-Swis -Hostname 192.168.25.30 -u "cscoengineer" -p "xxx"

    $AlertIDssrc=Get-SwisData -SwisConnection $swissrc -Query "select top 1 Name, AlertID from Orion.AlertConfigurations where enabled=1"

    foreach ($AlertID in $AlertIDsSRC) {
    $AlertIDDST = Get-SwisData -SwisConnection $swisdst -Query "select Name from Orion.AlertConfigurations where name='$($AlertID.Name)'"
    #Write-Output "SRC:$($AlertID.Name) DST:$($AlertIDDST.Name) XXX:$AlertIDDST"
    if ($AlertIDDst -eq $null) {
    Write-Output "Alert not in DST. Migrating Alert:$($AlertID.Name)"
    $ExportedAlertsrc=Invoke-SwisVerb $swissrc Orion.AlertConfigurations Export $AlertID.Alertid
    Set-Content ExportedXML.xml $ExportedAlertSRC.InnerText
    $AlertXML = Get-Content ExportedXML.xml -Raw
    Invoke-SwisVerb $swisdst Orion.AlertConfigurations Import @($AlertXML)
    }
    else
    {Write-Output "Alert in DST. Skipping: $($AlertID.Name)"}
    }