I'm trying to use a powershell Script in a Notification, but I can't get it to work correctly with parameters, that are Placeholders.
The Script I'm trying to run just writes a file containing the parameters and some other info.
I tried with standard parameters: "%sitename %device %name %status %down %message" -> I get no file at all, but as soon as I remove the %sitename, I get a file, but the other parameters aren't resolved, just passed as string %device, %name etc. (In the Notification Test) - which is normal I suppose, since there is no device that sent the event.
When I test this with a real device though ( I set the new Notification on a Ping sensor and then killed the Network Connection) I get no file again.
This is the Script:
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" ) $numbers = @(0000) $outpath = "\\server\sms\outgoing\" foreach ($number in $numbers){ $date = Get-Date $outfile = $outpath + $date.ToString("hhmmssfff") $outstr = "To: $number" + [System.Environment]::NewLine + [System.Environment]::NewLine $outstr= $outstr +"$SiteName $Device $Name $Status $Down $Message" $outstr | Out-File -FilePath $outfile -Encoding ascii } exit 0
Add comment