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.

Orion SDK Unmanage Script works then Remanages before its set to

I have a powershell script that uses a list of hostnames in a CSV to unmanage in mass via the Orion SDK. I have the results of the script exported to a log file. The Unmanage reports as successful however the node magically remanages itself before the UnManageUntil time. See screenshots below

Script ran at 4:45pm using UnManageFrom time of Now (4:45pm) to UnManageUntil time of Now + 6 hours (10:45pm).

AuditEents.JPG

However at 6:45pm the node is managed again. And triggers a reboot alert when rebooted during our maintenance window. This occurred for every node I unmanaged with my script so its not an isolated incident.

Events.JPG

Below is my powershell script. Is there something wrong with my script? What would make my nodes remanage exactly 2 hours after I unmanaged them and before they are set to?

Im running NPM 11.0.1 and SAM 6.1.1

Set-ExecutionPolicy RemoteSigned

Add-PSSnapin SwisSnapin

$HostnameList = @()

Import-Csv c:\Hostnames.csv | ForEach-Object {$HostnameList += $_.Hostname}

$cred = get-credential Admin

$swis = Connect-Swis -host "orionserver" $cred

$now=[DateTime]::Now

$later=$now.AddHours(6)


ForEach ($Hostname in $HostnameList)

{

$NodeID = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '$Hostname' OR DNS LIKE '$Hostname'"

$NodeIDStr = "N:" + $NodeID

Invoke-SwisVerb $swis Orion.Nodes Unmanage @($NodeIDStr,$now,$later,"false") -ErrorAction SilentlyContinue | Out-Null

    IF ($NodeID) {

        $Hostname + " " + $NodeID + " has been UnManaged from " + $now + " until " + $later | Tee-Object C:\UnManageLog.txt -Append

    }

    ELSE {

        $Hostname + " does not exist in SolarWinds or the Hostname is incorrect. Try FQDN." | Tee-Object C:\UnManageLog.txt -Append

    }

}

  • SWIS works in UTC. So when you pass in 10:45PM, it interprets that as UTC. The time shown in the audit message is also UTC, though it would be better if it were clearly labeled as such.

    I can infer from your post that you are in US Eastern Daylight Time (UTC-4), because at 6:45PM local time, your node went managed again. You can make the script behave as you want by changing this line:

    $now=[DateTime]::Now


    to this:

    $now=[DateTime]::UtcNow