Using custom detection scripts in apps
While we covered this briefly in Chapter 11, detection scripts work slightly differently from a PowerShell platform or remediation script, so this recipe will cover how they work and include some working examples.
How to do it…
The important thing to note with a custom detection script is it requires both an exit code (0
) and a standard output (STDOUT). Sending an exit code of 1
, or not including the STDOUT, will flag the installation as failed.
Before searching the STDOUT, the script must return an output. So, the following code will suffice and mark the installation as successful:
Write-output "App found" Exit 0
Now, we can use and deploy a custom detection script:
- To use a custom detection script, you must add the script during packaging or after deploying. For post-deployment, click on Apps, then Windows. Find the application in question and click on it.
- Now, click on Properties and click Edit next...