The attached Powershell script will unmanage/remanage/suppress/resume alerts for either a single node or for all members of a Solarwinds group, regardless of the kind of objects the group contains (Nodes, Applications, Transaction, etc.). If the group includes sub-groups, the script will recursively handle them. Credentials can be provided on the command line or in a credentials file created with Export-Clixml. The credentials file is useful if you plan to use this script with the Windows Task Scheduler and you don't want to include a username and password on the command line.
This script has been substantially revised from its previous version. Changes include:
To run this script from the Windows task scheduler without including the username and password on the command line follow the steps below:
set_solarwinds_unmanged.ps1 -server servername [(-group groupname) | (-hostname nodename)] [(-username username -password password])|(-credstore credential_store)] [-unmanage | -suppress] [-minutes minutes]
-server (Required): The name or IP address of the Solarwinds server.
-username (Optional): The name of a Solarwinds user that can unmanage and remanage
objects. If -username is specified, -password must also be specified. If -username
and -password are omitted, -credstore MUST be used.
-password (Optional): The password of a Solarwinds user that can unmanage and remanage
objects. If -password is specified, -username must also be specified. If -username
and -password are omitted, -credstore MUST be used.
-credstore (Optional): The path to a file containing the encrypted credentials of a
Solarwinds user that can unmanage and remanage objects. The encrypted file must be
created by the user on the server that will run the script, using the Powershell
command:
Get-Credential | Export-Clixml -Path [full path to file]
If -username is specified, -password must also be specified. If -credstore
is omitted, -username and -password MUST be used.
-group (Optional): The name of the Solarwinds group whose members are to be unmanaged,
remanaged, suppressed or resumed.
-hostname (Optional): The name of the Solarwinds node to be unmanaged,
remanaged, suppressed or resumed.
-unmanage (Optional): If the -unmanage flag is present, the script will attempt to
unmanage the node or all group members. If the -minutes flag is present, the script will
unmanage the group/node for the specified number of minutes. Included for backward compatibility.
-remanage (Optional): If the -remanage flag is present, the script will attempt to
remanage the node or all group members. Included for backward compatibility.
-suppress (Optional): If the -suppress flag is present, the script will attempt to
suppress alerts for the node or for all group members.
If the -minutes flag is present, the script will suppress alerts
for the specified number of minutes. Included for backward compatibility.
-resume (Optional): If the -resume flag is present, the script will attempt to
resume alerts for the node or all group members. Included for backward compatibility.
-minutes (Optional, default=60): An integer representing the number of minutes that the group should
be unmanaged. The unmanged period starts when the script runs. -minutes is ignored if -resume or
-remanage is specified.
-action (Optional): Replaces -unmanage, -remanage, -suppress, -resume. Must be one of the following:
unmanage, remanage, suppress, resume. The named -action replaces the flag of the same name.
Supply username and password on the command line, unmanage the group "Prd_Servers" for 1/2 hour
set_solarwinds_unmanaged.ps1 -server solarwinds.domain.com -group Prd_Servers -action unmanage -minutes 30 -username Me -password S3cr3t
Supply username and password in a credential file, unmanage the group "Prd_Servers" for 1 hour (the default)
set_solarwinds_unmanaged.ps1 -server solarwinds.domain.com -group Prd_Servers -action unmanage -credstore C:\Users\Me\credstore.xml
Remanage the group "Prd_Servers"
set_solarwinds_unmanaged.ps1 -server solarwinds.domain.com -group Prd_Servers -username Me -password S3cr3t -action unmanage
Remanage the group "Prd_Servers"
set_solarwinds_unmanaged.ps1 -server solarwinds.domain.com -group Prd_Servers -username Me -password S3cr3t -action remanage
Hi,
thank you very much for this script. its very useful.
What parameter i have to change for mute all items in a group?
THX
I've just uploaded a new version of this script that supports mute/unmute (suppress/resume alerts). To mute all items in a group you would use these parameters:
-G <groupname> -suppress -minutes <number of minutes to mute alerts starting now>
Looks really useful.
Typo on Example 1,2 & 3 (-Action Ommited in front of unmanage)
However cannot get past the Credential file function. Just get this. No idea where to look. Any ideas?
this is the command line:
C:\Users\UUUUUUUU>C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe C:\Scriptlib\SWHome\bin\set_solarwinds_unmanaged.ps1 -server NNNNNNNNNNNNNN -group GGG -action unmanage -minutes 30 -credstore C:\Scriptlib\SWHome\sec\sw_cred.xml
Using credentials from credential file System.Exception:
Could not fetch items from SWIS server NNNNNNNNNNNNNN .
Error details: System.Exception: Could not get group GGG members.
Error details: An unsecured or incorrectly secured fault was received from the other party.See the inner FaultException for the fault code and detail.
At C:\Scriptlib\SWHome\bin\set_solarwinds_unmanaged.ps1 :326 char:5
+ throw [System.Exception] "Could not fetch items from SWIS server",$server,". ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (System.Object[]:Object[]) [],
RuntimeException
+ FullyQualifiedErrorId : System.Exception: Could not fetch items from SWIS server NNNNNNNNNNNNNN .
Error details: System.Exception: Could not get group GGG members.
Error details: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
I was able to reproduce this error by creating a credentials file with a misspelled password. Please re-create the credentials file and try the script again.
Thanks for catching those errors in the script examples. I've fixed them in this document and in the scripts.
Hi there,
Tried that and got the same error, tried with user and password on command line no change.
However with a Solarwinds Account it works fine, so must be an issue with calling Active Directory.
m-milligan Thanks for this, works brilliantly, a couple more typos in the instructions but apart from that this is one on the most useful pieces of code I have seen recently... excellent
Typos for ref:
SYNTAX:
set_solarwinds_unmanged.ps1 -server servername [(-group groupname) | (-node-hostname nodename)] [(-username username -password password])|(-credstore credential_store)] [-unmanage | -suppress] [-action unmanage|remanage|suppress|resume][-minutes minutes]
COMMAND LINE PARAMETERS:
-hostname (Optional): The name of the Solarwinds node whose members are to be unmanaged,
remanaged, suppressed or resumed.
Glad it's working with a Solarwinds account. I have this working with an Active Directory account. When I created the credential file, I did not include the domain name in front of my username, i.e. I spelled it "username" instead of "DOMAIN\username". I haven't tested it with the domain name. Can you try omitting the domain name, if you've been including it?
Thanks for the catch on the typo. I'll fix those.
Yeah that works fine, great
Thanks
Ian
is there a shell or perl version of this?
Yes, there's a Perl version here: Unmanage nodes Perl script for Linux
Thanks for posting this script it was extremely helpful. I needed a way to unmanage/retire a node as an alert action if it had been down for >24 hours.
-The settings in the command only set it to unmanage for 2 minutes, adjust that for your need.
- ${N=SwisEntity;M=Caption} is a node variable for the node name
-I first installed the SDK on my lab server so I could run the commands
-Copied the script set_solarwinds_unmanaged.ps1 to C:\Scripts\
-Add the command below as an 'Execute an External Program' action in my alert.
powershell.exe c:\Scripts\set_solarwinds_unmanaged.ps1 -server YOURORIONSERVERNAME -hostname ${N=SwisEntity;M=Caption} -action unmanage -minutes 2 -username YOURUSERNAME -password YOURPASSWORD
Hello, I recently started using this and noticed a few limitations.
#1 - If I add components (ie. windows service, iis sites, iis app pools) into a group and try to unmanage it I get errors:
Invoke-SwisVerb : Verb Orion.APM.Component.Unmanage: Not found
#2 - If I add the AppInsight for IIS or SQL into a group and try to unmanage the group, I get a similar error as well:
Invoke-SwisVerb : Only applications can be unmanaged through this interface. ABIA:3600 does not refer to an
application.
Is this due to a limitation of Solarwinds itself or does the script need to be modified further to support individual components and AppInsight applications?
@m-milligan, first off, awesome script, it potentially solves the problem within the orion platform where you can't schedule regular maintenance periods.
I had two questions: if I run the script in task scheduler has the system account, with a .XML credential file that holds the username and password to temporarily disable the alerts, is it better to use a domain account of a local Orion account? While I don't think it would matter, I'm thinking if I use a locally created Orion account, which only has permissions to modify the alerts or unmanaged the node, and have it run either locally on the orion server or on our utility server, it should work; however, I'm not sure if this section will work if you are importing the encrypted creds while running the PS script via the system account:
"$cred = Import-Clixml -Path $credstore
$username = $cred.Username
$password = $cred.GetNetworkCredential().Password"
the second question is a request: since you are updating the code, can you include a version number and last date modified when you do make changes? this way we can make sure we are using the most up to date code.
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 150,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.