Quantcast
Channel: THWACK: Popular Discussions - Orion SDK
Viewing all articles
Browse latest Browse all 3719

Manage/Unmanage nodes via powershell

$
0
0

Hi,

 

I have tried to follow the below and I am stuck

Silence Group of Nodes

Powershell scripts to automatically unmanage\remanage a node using the Orion SDK

 

This is the script im using

 

# 2014-07-21 Node Unmanage script for SolarWinds SDK Powershell

# by Joe Dissmeyer | Thwack - @JoeDissmeyer | Twitter - @JoeDissmeyer | www.joedissmeyer.com

# This script will unmanage a single node in the Orion database. First, it finds the node number in the Orion database, then it will unmanage it for 99 years.

# This script assumes you are running it LOCALLY from an already managed node AND that the machine has the Orion SDK v1.9 installed on it.

# If the machine is not already managed in SolarWinds this script will fail without warning.

# Replace ORIONSERVERNAME with the appropriate values.

# ORIONSERVERNAME = Your Orion poller instance. (Ex. 'SOLARWINDS01.DOMAIN.LOCAL'). Single quotes are important.

 

# Load the SolarWinds Powershell snapin. Needed in order to execute the script. Requires the Orion SDK 1.9 installed on the machine this script is running from.

Add-PSSnapin SwisSnapin

 

 

# SolarWinds user name and password section. Create an Orion local account that only has node management rights. Enter the user name and password here.

$username = "test"

$password = "test123"

 

# This section allows the password to be embedded in this script. Without it the script will not work.

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

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

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

 

# The actual job

$ORIONSERVERNAME = 'slt-sol-app-99'
$nodename = $env:COMPUTERNAME

 

$swis = Connect-Swis -Credential $cred -host $orionservername

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE 'slt-jim-esx-562'"

$now =[DateTime]::UtcNow

$later =$now.{AddMinutes(20)}

Invoke-SwisVerb $swis Orion.Nodes Unmanage @("N: $nodeid ",$now,$later, "false")

 

But I get the error

 

Invoke-SwisVerb : no viable alternative at input '<EOF>' in Where clause

At H:\My Documents\Monitoring And Alerting\Solarwinds\Scripts\unmanage.ps1:58 char:16

+ Invoke-SwisVerb <<<<  $swis Orion.Nodes Unmanage @("N: $nodeid ",$now,$later, "false")

    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

 

On the first link above bluefunelemental says

 

"Try for each $node in $nodeid. As it is this is only pulling the one group ID on the loop"

 

And then theroberts says it worked without showing what he had done.  Can someone point me in the wright direction?


Viewing all articles
Browse latest Browse all 3719

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>