PowerShell Notifier
Use the PowerShell notifier to execute a PowerShell script when a device meets specified conditions.
To configure a PowerShell notifier:
- In the NIame text box, type a name for the notifier.
- From the Notifier Type menu, select PowerShell. The PowerShell Notifier configuration window is displayed.
- Specify how to execute the script on the local machine (localhost) or a remote machine.
- In the PowerShell arguments text box, enter the arguments to define how the PowerShell process executes. See below for more information.
- In the PowerShell command texttext box, type 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 text box and executes the specified command text.
- User - For Local execution, leave this field 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 - type the password associated with the supplied user name.
- PowerShell Arguments - type the arguments to be passed to the PowerShell command. These are command-line arguments used when launching PowerShell. These arguments control how PowerShell executes and are not sent to your PowerShell script.
- PowerShell Command Text - type the command to be executed. These are the commands that PowerShell runs when the notifier is triggered.
- The PowerShell Command Text box is limited to 255 characters. Typically this field is used to execute an existing script in a file.
- Command parameters are passed through STDIN and thus are not bound by a character limit. If you encounter a limit, you can use message variables as arguments, including sending the entire contents of the notifier message as an argument (${MESSAGE}). If you use one of these variables, make sure to enclose it in quotation marks, in case it contains whitespace.
- Relative paths to PowerShell scripts must be relative to the InterMapper Settings\Tools folder.
- Create additional folders hierarchy within the Tools folder if needed.
- 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.
- The PowerShell Command Text box is limited to 255 characters. Typically this field is used to execute an existing script in a file.
- Command parameters are passed through STDIN and thus are not bound by a character limit. If you encounter a limit, you can use message variables as arguments, including sending the entire contents of the notifier message as an argument (${MESSAGE}). If you use one of these variables, make sure to enclose it in quotation marks, 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 needed.
- 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.
Selecting an Execution Method
The following execution methods are available. Each one determines how the script is 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 text box and executes the specified command text.
Default Command Text
When you select an execution method, the PowerShell Command Text box is displayed with an appropriate command.
The defaults for each execution method are as follows:
- Local
./MyPowerShellNotifier.ps1 "${MESSAGE}"
- Alerting Device
Invoke-Command -FilePath ./MyPowerShellNotifier.ps1 -ArgumentList "${MESSAGE}"
- Other Device
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 text box.