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