I would suggest save the script as “script.ps1” for example.
Then use the BatchPatch Deployment feature ‘Actions > Deploy’ to deploy “script.ps1” to the target computer(s), and in the deployment configuration check the box that says “Retrieve console output…”
Lastly, before you run the deployment, you need to make one more change. Under ‘Tools > Settings > Remote Execution’ you need to change the ‘Deployment’ remote execution context setting to ‘Elevated token.’ This script will not run as SYSTEM, but when I tested as ‘Elevated token’ it worked.
-Doug