0

On Windows Server 2012, I'm trying to create a Scheduled Task, that runs as a Domain user, that copies a file from a different server to the local server, then deletes the file locally if the date modified is older than 30 minutes.

The powershell script I have works when I run it as my own admin account with Powershell and finishes without error.

I created the Scheduled Task and it too runs and the file is copied, and deleted if older than 30 minutes, but the task keeps running and never finishes.

The Event Log gives an Audit Failure error mentioning "SeTcbPrivilege".

The Domain user has permission to run batch scripts.

Powershell execution policy is Unrestricted.

I've tried configuring the Task with different arguments, including:

-ExecutionPolicy Bypass -file "C:\scripts\script01.ps1"

The task is set to store the password, run if not logged on, with highest privileges.

What else could I be missing?

I suppose the process could be finishing but the Task Scheduler GUI just isn't updating but in that case I'm concerned with the Audit Failure error.

I don't think the powershell script matters but this is the gist of it:

Copy-Item -Path \\server.example.com\directory\file.txt -Destination D:\directory\file.txt
Get-ChildItem -path D:\directory | where {$_.Lastwritetime -lt (date).addminutes(-30)} | remove-item
3
  • with highest privileges. Why? Is it an administrator account?
    – Greg Askew
    Jan 8, 2021 at 21:58
  • It's not an administrator account. I've tried 'with highest privileges' enabled and disabled and the script works either way but the 'audit failure' error is also present for both. Jan 8, 2021 at 22:51
  • As far as 'keeps running', I think it finishes but I need to refresh the window to see the updated status. The error still concerns me though. Jan 8, 2021 at 22:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.