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.

Invoke-SwisVerb : Verb Orion.AlertSuppression.SuppressAlerts cannot unpackage parameter 0 of type System.String

Import-Module SwisPowerShell

$OrionServer = 'localhost'
$cred = Get-Credential

$swis = Connect-Swis -Hostname $OrionServer -Credential $cred

$server = 'my-server'
$query = "SELECT Uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'"
$entityUris = Get-SwisData $swis $query
$entityUris = $entityUris |% {[string]$_}

Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris)

Trying to mute alerts on an object, using the code above and always receive the following error message:

Invoke-SwisVerb : Verb Orion.AlertSuppression.SuppressAlerts cannot unpackage parameter 0 of type System.String[]
At line:13 char:1
+ Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entity ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

Parents
  • I keep getting an error when trying to use the invoke-swisverb

    Invoke-SwisVerb : Access to Orion.AlertSuppression.SuppressAlerts verb denied.

    Has anyone else seen this?

  • This works on mine, 2023.1 and 3.1.0.343  SwisPowerShell. I wrote it while we were on 2020.2.4 so it was working on that version as well. 

    Take a look and compare. 

    cls
    Import-Module SwisPowerShell
    $swis = Connect-Swis -host MyHost@bobmarley.org -UserName BobMarley -Password LetsGet2getherItWillBeAllRight
    #$swis = Connect-Swis -host MyHost@bobmarley.org -trusted
    $entityUris = Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE SysName LIKE'MYSERVERNAME'"
    $entityUris = @( $entityUris |% {[string]$_} )
    $now =[DateTime]::Now
    $later =$now.AddMinutes(5)
    Write-host "Muting Node from time in UTC $now until $later"
    Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris, $now, $later ) | Out-Null
    

  • I still get the invoke-swis access to orion verb error.

    I tried it once like this.

    Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris, $now, $later ) | Out-Null

    I also tried adding the parameter names before the variables.

    Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.AlertSuppression -Verb SuppressAlerts -Arguments @($entityUris, $now, $later ) | Out-Null

    Invoke-SwisVerb : Access to Orion.AlertSuppression.SuppressAlerts verb denied.
    At line:1 char:1
    + Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entity ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

  • Did you try changing these values so they match your environment and run this script? This one worked in my environment.

  • Can you verify if the account you use to create swisconnection have enought right to mute/unmute object ?

    nodes = Get-SwisData $swis -Query "SELECT Uri FROM Orion.Nodes WHERE SysName LIKE 'MYSERVERNAME'"

    foreach ($Uri in $nodes) {
    Invoke-SwisVerb $swis -EntityName Orion.AlertSuppression -Verb SuppressAlerts -Arguments @( [string[]] $Uri, (Get-Date), (Get-Date).AddHours((99)))
    }
  • I tried the code that you posted and it doesn't work. The code posted below is very close and does work. This will mute the node indefinitely. 

    Import-Module SwisPowerShell
    
    #$OrionServer = 'localhost'
    #$cred = Get-Credential
    #$swis = Connect-Swis -Hostname $OrionServer -Credential $cred
    $swis = Connect-Swis -host MYORIONSERVER -Trusted #This is using the AD Account I am logged in as and I have admin rights in Orion
    
    $server = 'SERVERIWANTTOMUTE'
    $query = "SELECT Uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'"
    $entityUris = Get-SwisData $swis $query
    $entityUris = $entityUris |% {[string]$_}
    
    #Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris)
    Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris, [DateTime]::UtcNow) #This muted the node indefinitely

Reply
  • I tried the code that you posted and it doesn't work. The code posted below is very close and does work. This will mute the node indefinitely. 

    Import-Module SwisPowerShell
    
    #$OrionServer = 'localhost'
    #$cred = Get-Credential
    #$swis = Connect-Swis -Hostname $OrionServer -Credential $cred
    $swis = Connect-Swis -host MYORIONSERVER -Trusted #This is using the AD Account I am logged in as and I have admin rights in Orion
    
    $server = 'SERVERIWANTTOMUTE'
    $query = "SELECT Uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'"
    $entityUris = Get-SwisData $swis $query
    $entityUris = $entityUris |% {[string]$_}
    
    #Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris)
    Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris, [DateTime]::UtcNow) #This muted the node indefinitely

Children
  • Lol ok

    I use it on my instances, so yes, it works. (mute for 99 hours in this case)

    (edit : ok my bad  the threads layout is confusing)

  • Sorry @ it was in reply to the code @ was trying to use. It didn't work when I tried it. 

    Your looks great!

  • @bobmarley Thank you for the update.

    I keep getting an error where access to orion.alertsupression.supressalerts verb denied.

    I am using an account that has admin permissions.


    Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris, [DateTime]::UtcNow) #This muted t
    he node indefinitely
    Invoke-SwisVerb : Access to Orion.AlertSuppression.SuppressAlerts verb denied.
    At line:1 char:1
    + Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entity ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

  • Are you running Powershell as administrator? Right Click Run As Administrator

  • Yes, I have tried both in administrator mode and not in administrator mode.

  • Hi ,

    Having PowerShell run as an administrator shouldn't be necessary. I'm thinking that it might be an issue with the formatting of the arguments.

    This is what works for me:

    #  The formatting of the arguments as an Array (like below) is not necessary
    Invoke-SwisVerb -SwisConnection $Swis -EntityName Orion.AlertSuppression -Verb SuppressAlerts -Arguments @(@($Uri), $StartTime, $EndTime)
    
    
    #  But the first argument, the entityUris, must be an Array:
    Invoke-SwisVerb -SwisConnection $Swis -EntityName Orion.AlertSuppression -Verb SuppressAlerts -Arguments @($Uri), $StartTime, $EndTime
    
    
    # As a bonus, this means that you can pass multiple entities on the same invoke, instead of having to run the invoke in a foreach loop. Example:
    $Uris = @(
        'swis://orion.example.com/Orion/Orion.Nodes/NodeID=1234',
        'swis://orion.example.com/Orion/Orion.Nodes/NodeID=1235'
    )
    Invoke-SwisVerb -SwisConnection $Swis -EntityName Orion.AlertSuppression -Verb SuppressAlerts -Arguments @($Uris), $StartTime, $EndTime

    I've found that if I look at the verb in SWQL Studio, I can see if the value is expected as a Array. You can find that here:

    Even though it says that it's expecting a string, the XML is looking for an array. This is the "how to understand swql/api" that helped me out the most.