If you are trying to run a PowerShell Script through Windows Task scheduler in a Windows server using a service account like me, at the end of task scheduler a warning message was shown that the service account need ‘Log on as batch job access’ to run the job.
Here is a blog which explains how to schedule PowerShell script to run from task scheduler
If you try to run the job without providing log on as a batch access to the account running the job, you will get an error with OpCode: Launch Failure – Task Scheduler failed to start the task xyz.
Here are the steps to set up Log on as a batch job access for an account or group through Local Security Policy. This access can also be granted through Domain Security Policy.
1. Go to Control Panel, select Administrative Tools
2. Open ‘Local Security Policy‘