Powershell – Windows 2008 R2 Scheduled Task Not Running With Admin Privileges even if granted

powershellscheduled-taskscriptingwindows-server-2008windows-server-2008-r2

I have a scheduled task that is running as USER. I have checked the box "Run with highest privileges" in the scheduled task properties. The task is a powershell script that, among other things, reboots the system. The script executes and runs normally, but as a scheduled task, it fails to reboot the system.

Here is the kicker: When I manually run the script as USER using the exact same command line as what's in the scheduled task, the script still runs but this time it actually reboots the system.

I have UAC disabled and USER is a member of the local Admins group. The local Admins group has the right to shut down the system. Nothing in the event logs offers any clues.

Why would the same script running under the same credentials work interactively but not as a scheduled task?

UPDATE: This is too weird. When the task ran on schedule, everything worked normally.

Best Answer

If you're running this as a power shell command you'll want to include the -Force option.