How to mute node with Powershell

I have a script working now to unmanage nodes, however cannot get anything to work to mute them.  Please advise if anyone knows.

Import-Module SwisPowerShell

$swis = Connect-Swis -Credential $mycredentials -Hostname ....

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE'dbprod1a'"

$now =[DateTime]::Now

$later =$now.AddYears(99)

Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @("N:$nodeid",[DateTime]::UtcNow) | Out-Null

Parents
  • Here is working code I tested in March 2021 on V2020.4

    Add-PSSnapin SwisSnapin
    #This will use your currently logged in AD account
    $swis = Connect-Swis -host YOURORIONHOSTNAMEHERE -Trusted

    #This lets you use an orion local account and password
    #$swis = Connect-Swis -host YOURORIONHOSTNAMEHERE -UserName YOURNAME -Password YOURPASSWORD

    ##Place the name of the node you want to mute in the NODENAMEYOURSEARCHINGFOR field
    $entityUris = Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE caption LIKE 'NODENAMEYOURSEARCHINGFOR'"
    $entityUris = @( $entityUris |% {[string]$_} )

    # Begin Alert Suppresion
    Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris, [DateTime]::UtcNow) | Out-Null

    # End alert suppression - uncomment, and comment supression line above
    #Invoke-SwisVerb $swis Orion.AlertSuppression ResumeAlerts @(,$entityUris) | Out-Null

Reply
  • Here is working code I tested in March 2021 on V2020.4

    Add-PSSnapin SwisSnapin
    #This will use your currently logged in AD account
    $swis = Connect-Swis -host YOURORIONHOSTNAMEHERE -Trusted

    #This lets you use an orion local account and password
    #$swis = Connect-Swis -host YOURORIONHOSTNAMEHERE -UserName YOURNAME -Password YOURPASSWORD

    ##Place the name of the node you want to mute in the NODENAMEYOURSEARCHINGFOR field
    $entityUris = Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE caption LIKE 'NODENAMEYOURSEARCHINGFOR'"
    $entityUris = @( $entityUris |% {[string]$_} )

    # Begin Alert Suppresion
    Invoke-SwisVerb $swis Orion.AlertSuppression SuppressAlerts @($entityUris, [DateTime]::UtcNow) | Out-Null

    # End alert suppression - uncomment, and comment supression line above
    #Invoke-SwisVerb $swis Orion.AlertSuppression ResumeAlerts @(,$entityUris) | Out-Null

Children
No Data