Some of the scripting I’ve recently done requires Excel to be launched (non interactively) on a domain controller to gather usernames and whatnot. For some reason, the entire script would work perfectly besides the portion that requires Excel. I could run the script as an admin in ISE and it would work, but not via the Task Scheduler.
Here’s the fix:
Create these two folders on your server:
Powershell and the Task Scheduler apparently need these two folders when running Excel.
Hope this helps! Cheers!