I want to create ScheduledTask (using powershell) with the following requirements:
- Use specific Domain User
- Run whether user is logged on or not
- Store password because I need access to shares on another servers.
It looks like I can use “New-ScheduledTaskPrincipal” for “Run whether user is logged on or not”
But in this case password is not saved.
I don’t know if I can supply password with “New-ScheduledTaskPrincipal”.
My commands are
$principal = New-ScheduledTaskPrincipal -UserID "MYDOMAIN\user_for_scheduled_task" -LogonType S4U -RunLevel Highest Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Task-1" -Description "Very Important Task-1" -Principal $principal
After executing these commands I see “Do not store password” checked in “Task Scheduler”.
And when I tried to manually run “Task” in “Task Scheduler” I am getting “PermissionDenied” during external server share access in script transcript.
How can I allow access to external shares for Register-ScheduledTask ?