I'm trying to mute alerts by powershell , i'm able to connect solarwinds but not able to get nodeID.
i tried many times by changing the query in below script . but no use...please assist me
$serverName = "abcdef"
$solarWindsServer = "SOLARWINDS"
# Define your SolarWinds server and credentials
$username = "a-v-cds"
$password = ConvertTo-SecureString "Password" -AsPlainText -Force
$Credential = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist ($username, $password)
# Connect to the SolarWinds server
try{
$swisConnection = Connect-Swis -Hostname $solarWindsServer -Credential $credential
$query = "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '%$serverName'"
$nodeId = (Get-SwisData -SwisConnection $swisConnection -Query)
$now =[DateTime]::Now
$later =$now.AddDays(1)
Write-Host $now
$nodeId = @( $nodeId |% {[string]$_} )
Invoke-SwisVerb $swisConnection Orion.AlertSuppression SuppressAlerts @($nodeId,$now)
}
catch{
Write-Host "Error: $_"
}