0

I have written a PowerShell script that copies files from one mapped drive to another. Script runs fine when I run through PowerShell or command prompt. It mounts the both drives first and then wait for 10 second and then copies the files.

I now want to run the same script in Task scheduler but getting error.

Logon failure: the user has not been granted the requested logon type at this computer.

enter image description here

Task is configured to run with my account and I can run script in command prompt without any error. Is there any special permissions required for Task scheduler?

The script I used to map the drive

$LibraryURL =http://corpapps/cloud/documentLibary"
$Network = new-object -ComObject WScript.Network
$Network.MapNetworkDrive('D:', $LibraryURL)

1 Answer 1

-1

Our Windows Task scheduler's PS script runs with a service account that has to be granted Log on as a service privilege in the Local Security Policy on the Server.

Local Security Policy=> Local Policies => User Rights Assignments => Log on as a service.

You can check if your account has that privilege on your local computer.

You can try also granting "Log on as a batch job"

2
  • but which service account needs permissions? The account I used to trigger the job as shown in picture?
    – Ali
    Commented Dec 10, 2020 at 2:57
  • I already have log on as a service rights but i don't have log on as a batch job rights.
    – Ali
    Commented Dec 10, 2020 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.