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
LVL 1
LN41Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
$command2= & psexec -s cmd.exe /c "symdg list" | out-file $logfile -Append

download psexec.exe from sysinternals
http://technet.microsoft.com/en-us/sysinternals/bb897553
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LN41Author Commented:
Tried using psexec but same result. :(
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.