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.


Article Comments

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


Jun, 2013 - Permalink