I am trying to perform an automatic backup of some files and folders based on a configuration. This is done using Powershell 5 which in turn relies on Background Intelligent Transfer Service (BITS). E.g.:
Start-BitsTransfer $Source\* $Destination -RetryInterval 60 -RetryTimeout 600
Powershell scripts are run using a bat:
powershell -ExecutionPolicy unrestricted .\Main.ps1
The batch is executed using a Scheduled Task:
User account: AD service account
Run: whether user is logged on or not
When I run the batch directly using the same account set on scheduled task, it runs perfectly. When I run it from the Task scheduler, BITS operations issue the following error:
The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (Exception from HRESULT: 0x800704DD)
I tried to change the user for BITS service, by setting it to the same service account I use for the scheduled task, but the service does not start anymore:
The Background Intelligent Transfer Service service failed to start due to the following error:
The account specified for this service is different from the account specified for other services running in the same process.
Going back to the scheduled task, I have changed to run "only when user is logged on". Of course, this would make sense only if I set autologon on this user (otherwise, it will not run if not logged in).
Question: How can I automate a backup using BITS without relying on tricks such as autologon?