System account cannot run commands in script

I have a problem with a script running under the system account. I'm using powershell to run a command at the command line and then send the output nightly to a log file.

When I run the below script at the command prompt, it works.

When running the below script as a scheduled task under my own account in the task scheduler, it works.

When running the command as the system account in the task scheduler, it will write the start time to the log file ($command1) but will not run $command2. No errors show at all.

Another odd item is that I can use psexec to run a command window as the system account and run the the $command2 and it works.

Is there any security or other setting that would prevent the system account from running $command2 when running the script from a scheduled task?

Here's the script:

$logfile = "C:\logs\testlog.log"
$date = get-date

# write start time to log
$command1 = ("#### Script ran at: " + "$date") | out-file $logfile -Append
$command2 = & cmd /c "symdg list" | out-file $logfile -Append
Who is Participating?
Raheman M. AbdulConnect With a Mentor Senior Infrastructure Support Analyst & Systems DeveloperCommented:
$command2= & psexec -s cmd.exe /c "symdg list" | out-file $logfile -Append

download psexec.exe from sysinternals
LN41Author Commented:
Tried using psexec but same result. :(
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.