cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

Unmanage/remanage or mute/resume an item or all items in a group

Description

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.

Changes

This script has been substantially revised from its previous version. Changes include:

  • Script supports suppress/reset (aka mute/unmute) of alerts in addition to unmanage/remanage.
  • Script can be run against a single node or against a group

Run from Windows Task Scheduler

To run this script from the Windows task scheduler without including the username and password on the command line follow the steps below:

  1. Log in to the Task Scheduler server as the user under whose name the task will run.
  2. Start the Powershell IDE and execute the command below to create the encrypted credentials file:
    Get-Credential | Export-Clixml -Path [full path to file]
  3. Start the Task Scheduler and create a task to run the script. Open the properties.
  4. In the "Actions" tab, make sure that the script is configured to use the -credstore argument with the full path to the credentials file from step 2.
  5. In the "General" tab, configure the task to run as the user you logged in as in step 1.
  6. Save the task.

Syntax

set_solarwinds_unmanged.ps1 -server servername [(-group groupname) | (-hostname nodename)] [(-username username -password password])|(-credstore credential_store)] [-unmanage | -suppress] [-minutes minutes]

Command line parameters

-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.

Examples

Example 1

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

Example 2

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

Example 3

Remanage the group "Prd_Servers"

         set_solarwinds_unmanaged.ps1 -server solarwinds.domain.com -group Prd_Servers -username Me -password S3cr3t -action unmanage

Example 4

Remanage the group "Prd_Servers"

         set_solarwinds_unmanaged.ps1 -server solarwinds.domain.com -group Prd_Servers -username Me -password S3cr3t -action remanage

Attachments
Comments

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

@ m-milligan

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

Version history
Revision #:
1 of 1
Last update:
‎01-28-2016 03:13 PM
Updated by: