Unmanage All Nodes with a Specified Custom Property Value

Version 1

    The attached allows you to Unmanage a group of nodes that share a custom property value in common. This is useful when you plan to take an entire site down for maintenance, or if you have a scheduled patching routine you'd like to automate.

     

    Using the Orion SDK you can accomplish this using PowerShell. For example:

     

         $swis = Connect-Swis -hostname XXX -username YYY -password ZZZ

         $nodes = Get-SwisData $swis "SELECT N.Uri FROM Orion.Nodes N WHERE N.CustomProperties.Foo = @bar" @{ bar = "my value" }

         $nodes | Set-SwisData $swis @{ Unmanaged = $true; UnmanageFrom = [DateTime]::UtcNow; UnmanageUntil = [DateTime]::UtcNow.AddHours(4) }

     

    The above is a simplified example of the logic someone might use to accomplish this by unmanaging all nodes which have the Custom Property ‘Foo’ set with the value of ‘bar’.  Once complete, you would then use the Scheduled Task Manager to run this PowerShell script on a regularly scheduled basis. 

     

    Attached is a more practical implementation which should serve as a proof of concept. Simply run:

     

         ‘UnmanageByCustomProperty.ps1 -server {orion server name or IP address} -customProperty "{custom property name}" -value “{custom property value}"

     

    Note: The Orion username and password is hardcoded within the script and should be changed to match your environment.