# This script will search for nodeid and Unmanage it if exists
################################## Attention ###############################################
# You must have Orion SDK installed and set-execution policy must be set to unrestricted!!#
#Before running you must setup your hashed encrypted password using the line below. #
###########################################################################################
#### Prerequisites ###
## run the line below save credentials to be used by this script on an encrypted file
#GET-CREDENTIAL –Credential "EnterTheOrionUserNamehere” | EXPORT-CLIXML C:\Scripts\SecureCredentialsSAM.xml
## run the line below Install SolarWinds Powershell Module - source: PowerShell Gallery | SwisPowerShell 2.4.0.176
# Install-Module -Name SwisPowerShell
## run the line below Load the SolarWinds Powershell Module.
Import-Module -Name SwisPowerShell
# SolarWinds username and password section.
# It is recommended to use a local account created within SAM with only. I strongly recommend that you don't use a MS local account or domain account.
# This section allows the password to be embedded in this script. Without it, the script will not work.
#This is using the hashed encrypted password
$MyCredentials= IMPORT-CLIXML C:\Scripts\SecureCredentialsSam.xml
$ORIONSERVERNAME= 'yourserver.domain.com'
$Servername= 'thenodeNAMEgoeshere'
#This is connecting to SAM to pull the info we need with the info given
$swis = Connect-Swis -Credential $MyCredentials -host $ORIONSERVERNAME
$nodeId = Get-SwisData $swis "SELECT NodeId FROM Orion.Nodes WHERE NodeName LIKE '%$Servername'"
#get time
$now =[DateTime]::UtcNow
#unamage durantion
$later =$now.AddMinutes(30)
Invoke-SwisVerb $swis Orion.Nodes Unmanage @("N: $nodeid ",$now,$later, "false")
# To remanage the node run:
# Invoke-SwisVerb $swis Orion.Nodes Remanage("N: $nodeid")