The environment in which a script runs when triggered by Task Scheduler might differ from when it's run interactively. Ensure that the script does not depend on any specific user settings or environment variables that might be different when running under Task Scheduler.
Problem getting a powershell script to run in Task Scheduler
Hello.
I am trying to get a PowerShell script to run once every half hour in the Task Scheduler utility. The platform is Windows Server 2019 Standard Edition. I configured the script to run on a schedule starting at 12:00 AM every day, and repeat every 30 minutes indefinitely.
The script is designed to do a check of disk space usage on several remote servers, and email the results as an attached html file. The user account that is associated with the script does have Administrator access on all servers. The script itself is configured to run whether the user account is logged in or not, and also with the highest privileges.
I have confirmed the script will run by interactively running it in Powershell, and also when I click on 'Run' within the Task Scheduler. According to the Last Run Result, the script ran successfully, but the email with the attached html file is not being sent to the intended recipient.