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.

Unable to put nodes in maintenance mode with SDK since upgrading

I now get an error from the power shell script i got from the sdk github page. Here is the error i'm getting.

Get-SwisData : An error occurred when verifying security for the message.

At line:19 char:13

+     $uris = Get-SwisData $swis $strQuery

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [Get-SwisData], MessageSecurityException

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.GetSwisData

here is line 18 and 19

    [String]$strQuery = "SELECT uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'" 

    $uris = Get-SwisData $swis $strQuery

Does anyone have any idea why i'm getting this since upgrading to Orion Platform 2018.4 HF1. Here is the full script

#Region PSSnapin presence check/add 

if (!(Get-PSSnapin -Name "SwisSnapin" -ErrorAction SilentlyContinue)) 

{     

    Add-PSSnapin SwisSnapin -ErrorAction SilentlyContinue 

#EndRegion 

$serverlist = Get-Content -Path "C:\Temp\unmanageservers.txt" 

$username = "user"

$password = "password"

$secstr = New-Object -TypeName System.Security.SecureString

$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

$strOrionServer="solarwinds" 

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

foreach($server in $serverlist){ 

 

    [String]$strQuery = "SELECT uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'" 

    $uris = Get-SwisData $swis $strQuery

 

 

    $uris | ForEach-Object { Set-SwisObject $swis $_ @{Status=9;Unmanaged=$true;UnmanageFrom=[DateTime]::UtcNow;UnmanageUntil=[DateTime]::UtcNow.AddHours(2)}}  

}

  • After a lot of reading and looking at other scripts i changed "-Credential $cred" to "-Trusted" and it worked. I've tested it several times and it's working fine now.

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

    $swis = Connect-Swis -Hostname $strOrionServer -Trusted