New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


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

Votes:

1

Your Vote:

Up

Down

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 by  jgsong (1) 1

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



1 Reply

Accepted Answer

Votes:

1

Your Vote:

Up

Down

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]



Please log in or register to enter your reply.


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.