I am trying to get Windows Task Scheduler to run a PowerShell script. I have a script file with the following code.
[System.Windows.MessageBox]::Show('Hello')
This script runs fine when I run it using the PowerShell program. I’ve tried to run it with Task Scheduler on Windows using the instructions in this article. https://community.spiceworks.com/how_to/17736-run-powershell-scripts-from-task-scheduler But I just get a blue window that closes quickly with red text that I can’t read before it closes. How do I run this script from Task Scheduler?
So you may add temporarily the parameter -NoExit to the “Add Arguments” section of the task scheduler and maybe add a Start-Sleep at the end of your script. So you can see the error message.