This script runs continously to monitor MDT deployments and sends email alerts when depoyments finish. This is best used as a Windows service. To create a service easily - try NSSM https://nssm.cc/download
To install and use (must be installed on MDT server with monitoring enabled)