Use the same PowerShell script for both detection and remediation.
Schedule the script to run as often as required.