I'm running two PowerShell scripts as scheduled tasks on multiple servers. One script (#1) moves folders from one application to another folder (trash), the other script (#2) restarts services.
Script #1 moves folders by copying them to a destination path and then deleting the folder in the source path. The script works when running manually in a PowerShell console, but when it runs as a scheduled task it doesn't copy folders to the destination path, but it does delete the folder in the source path.
Script #2 restarts MySQL and IIS on two servers, but it usually fails to restart MSSQL on a third server. When I check the scheduled task history, the script runs for 30 minutes before its forced to stop by the scheduler. It restarts a single MSSQL instance so it should only take a few minutes at most.
Both scripts are running with highest privileges with -ExecutionPolicy Bypass and the Start In folder is set to their installation path. I get error (2) for Operational Code in History. This is a file not found message. Each script uses an XML file for settings.
Does anyone have any ideas what I may be missing for the script to run unattended?
Thanks.