PDQ command line: args outside of script (PRTG > PDQ)
Hello,
Probably a basic question, but if I have script such as
Invoke-Command -ComputerName prtgserver.domain.co.uk -ScriptBlock {pdqdeploy.exe Deploy -Package "Wake Up" -Targets $args[0]} -Args $env:COMPUTERNAME 2>&1
How do I edit the script so I can pass the computername argument outside of the script instead? I'm using PRTG, which can send a command when a sensor enters a particular state (eg run a program when endpoint is offline).
In PRTG, I have to specify the ps1 location, file name, then any arguments. PRTG's variable for the computer name is %host
Background
We use PRTG to monitor our infrastructure. PRTG can fire a "notification" when an sensor enters a particular state. For example, for an endpoint, I have a 'Ping' sensor, which goes into a down state when the endpoint is offline. I can create custom notifications which can run a program (powershell, batch file, vbs, etc) when this sensor enters this down state. I have a PDQ package which send a WOL packet, but need to invoke this from PRTG using the %host variable from PRTG.
Thanks in advance.
Comments
You can use a param block to pass data into a PowerShell script when you call it.
Here's a couple examples of calling this script:
Amazing! Thanks Colby. This works perfectly when testing on its own. It doesn't work in PRTG - so I need to take it up with them and see what's happening and try to get the logs.
I'll post back here with a solution.