This isn’t the answer why your specific script doesn’t work under the SYSTEM account but explains how you might troubleshoot your (or any other) PowerShell Script under the SYSTEM account.
Give a man a fish, and you feed him for a day. Teach a man to fish,
and you feed him for a lifetime.
The whole thing around this, is that you can actually open a interactive PowerShell command prompt under the SYSTEM account were you probably not aware of.
Run PowerShell as SYSTEM
There are a few ways to start a interactive PowerShell command prompt but probably the easiest one is using PsExec.
PSTools.zipand just copy
PsExecinto your executable path
PowerShellas Administrator (accept the
- In the PowerShell administrator window, give the command:
.\PsExec -i -s -d PowerShell
- A new
PowerShellcommand window will open:
WhoAmIto confirm the current account)
From here you can troubleshoot the specific script:
- Are there any errors when running the specific script?
- Does it hang or crash at a specific command?
- Are there any differences with running it under a user account?
If it appears that the script runs actually fine in the SYSTEM window, then I would check for any errors in the
Task Scheduler Local–
Task Scheduler Libraryin the left pane
- Select your task in the middle top pane
- (Make sure you have
Display All Task Historyin the right pane
- In the middle bottom pane check the events in the