1

In a 2008 R2 server, I have a Windows task that executes a PowerShell script that uses Get-EventLog to get Windows event logs from the local server and also from servers over the network. When running the script manually from the PowerShell command prompt, the script works fine. But when running it from the Windows task scheduler, the script only gets the logs from the local server, not from the other servers.

I was able to get it to work by unchecking the "Do not store password. The task will only have access to local resources." checkbox in the task's properties. But we want to avoid that for security reasons. We also don't want to disable the local security policy "Network Access: Do not allow the storage of passwords and credentials for network authentication" in order to get this to work...

Is there another way to get our task to successfully run our script and get the event logs of our servers over the network?

72909903
  • 39
  • 5

1 Answers1

1

A PS-script obtains a user permission, who has run it. You should create domain user with membership in Event Log Readers group and then configure "run as" created user in Task Scheduler.

batistuta09
  • 8,981
  • 10
  • 23
  • 1
    I created a domain service account to run the task, made sure to give it "log on as a batch job" rights, put the account in the local administrators group (just for testing right now) and set up the task to "run as" this domain service account. But when running the task now, the message is "logon failure: unknown username or bad password (0x8007052E)". When I uncheck the "Do not store password. The task will only have access to local resources." checkbox, the task runs fine with the domain service account. But we don't want to do that, we want that box to be checked for security reasons... – 72909903 Mar 27 '19 at 20:58
  • 1
    Looks like due to the limitations of the Task Scheduler with the "Do not store password" checkbox which we need to keep checked, we've had to just settle for a manual workaround. We created a desktop shortcut to execute the script which works fine. – 72909903 Apr 10 '19 at 20:47