PowerShell Notifier
Use the Powershell notifier to execute a PowerShell script when a device meets specified conditions.
Note: Before you can run a PowerShell Notifier, you must configure PowerShell to work with InterMapper(Pg 1) on the local machine and any target machines you want to access with PowerShell. Use PowerShell probes to test the connectivity.
To configure a PowerShell notifier:
- Enter a notifier Name.
- From the Notifier Type dropdown menu, choose PowerShell. The PowerShell Notifier configuration window appears as shown below.
- Choose whether you want to execute the script on the local machine (localhost) or a remote machine.
- In the PowerShell arguments box, enter the arguments you want to use define how the PowerShell process executes. See below for more information.
- In the PowerShell command text box, enter the command you want to execute. See below for more information.
PowerShell Notifier Settings
- Execution - Choose how the script or command is executed:
Local - the PowerShell command text is executed on the local machine.
Alerting Device - Powershell uses the selected Authentication method to connect to the machine that triggered the alert, and executes the specified command text.
Other Device - Powershell uses the selected Authentication method to connect to the machine specified in the ComputerName box, and executes the specified command text.
- User - For Local execution, leave this blank unless you want to pass credentials to your script, (for example, to use Get-WmiObject). For Remote execution, use the credentials of a valid administrator on the remote computer. For networks that do not use a domain controller, a notifier must be created for each unique administrator.
- Password - enter the password associated with the supplied user name.
- PowerShell Arguments - enter the arguments to be passed to the PowerShell command. These are command line arguments used when launching PowerShell; they control how PowerShell executes, and are not sent to your PowerShell script.
- PowerShell Command Text - enter the text of the command to be executed. These are the commands that PowerShell runs when the notifier is triggered.
Notes:
- The PowerShell Command Text box is limited to 255 characters. Typically it is used to execute an existing script in a file.
- Parameters to the command are passed through STDIN, and thus are not bound by the character limit. If you encounter the limit, you can use message variables as arguments, including sending the entire contents of the notifier message as an argument ("${MESSAGE}"). If you choose to use one of these variables, be sure to enclose it in quotes, in case it contains whitespace.
- Relative paths to PowerShell scripts must be relative to the InterMapper Settings\Tools folder.
- You can create additional folders hierarchy within the Tools folder if you find it useful.
- In the Command Text box, the path to the Tools folder is "./yourscript.ps1". PowerShell also accepts a backslash, but it must be escaped: ".\\yourscript.ps1."
- Signed scripts must be run from the InterMapper Settings\Tools folder or in a folder it contains.
Available Variables
You can use many InterMapper variables, including ${address}, ${User}, ${Password*}, as well as any of the other information available to Command-Line notifiers.
Choosing an Execution Method
Three methods of execution are available. Each one determines how the script will be executed, and what device it is executed on.
- Local - the PowerShell command text is executed on the local machine.
- Alerting Device - Powershell uses the selected Authentication method to connect to the machine that triggered the alert, and executes the specified command text.
- Other Device - Powershell uses the selected Authentication method to connect to the machine specified in the ComputerName box, and executes the specified command text.
Default Command Text
When you choose an execution method, the PowerShell command text box is preloaded an appropriate command.
Here are the defaults for each execution method:
./MyPowerShellNotifier.ps1 "${MESSAGE}"
Invoke-Command -FilePath ./MyPowerShellNotifier.ps1 -ArgumentList "${MESSAGE}"
Invoke-Command -FilePath ./MyPowerShellNotifier.ps1 -ArgumentList "${MESSAGE}"
Change the name of the .ps1 script and change or add parameters as needed.
Execution: Local Device
The specified command text is executed on the local machine.
Execution: Alerting Device
The specified command text is executed on the machine that triggered the alert.
Execution: Other Device
The specified command text is executed on the machine specified in the ComputerName box.