What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I use the parameters of a notification in a Powershell script?

Votes:

1

When a website on a remote server is down, I want to restart the Application Pool. For this purpose, I added a notification to PRTG which executes a ps1 Powershell script I wrote. Unfortunately, I don't know how can I use the parameters which are provided by PRTG in the Execute Program section of the Notification settings (e.g., %device, %name, etc.).

The parameters I use in my script do not work. Please help me to provide the correct parameters in my script.

exe execute-program notification parameters powershell ps1

Created on Jun 5, 2013 3:04:03 AM

Last change on Jun 11, 2013 1:07:07 PM by  Gerald Schoch [Paessler Support]



1 Reply

Accepted Answer

Votes:

1

Hi,

the parameters can be set in the 'Execute Program'-part of the notification settings. If you are using the default parameters your script should look like

param(
    [string]$SiteName = "N/A",
    [string]$Device = "N/A",
    [string]$Name = "N/A",
    [string]$Status = "N/A", 
    [string]$Down = "N/A",
    [string]$Message = "N/A"
    )

$username = "xxxx" 
$password = "xxxx" 
$secstr = New-Object -TypeName System.Security.SecureString $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} 
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr

Invoke-Command -ComputerName '$Device' -Credential $cred -Command { 
    Import-Module WebAdministration (Get-Item 'IIS:\AppPools\xxxxxx').stop() (Get-Item 'IIS:\AppPools\xxxxxx').start() 
}

to receive the given parameters.

Kind Regards

Created on Jun 5, 2013 12:06:51 PM by  Dieter Loskarn [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.