I'm creating Scheduled Job via Powershell but I can't set this options/setting to either create Task without 'Don't store password. The task will only have access to local resources' or change it afterwards.
I've written the following code to create scheduled job, but task is created with checked setting 'don't store password' and it does not have access to local network. I don't want to change it manually via Task Scheduler GUI.
$task_path = 'path to file'
$scheduled_job_options = New-ScheduledJobOption -WakeToRun -StartIfIdle -ContinueIfGoingOnBattery
$scheduled_job_triggers = New-JobTrigger -Once -At "10:00AM" -RepetitionInterval (New-TimeSpan -Hours 6) -RepetitionDuration ([TimeSpan]::MaxValue)
Register-ScheduledJob -Name "Collect Logs" -FilePath $task_path -ScheduledJobOption $scheduled_job_options -Trigger $scheduled_job_triggers -Credential $credential
I've also tried to remove supplying credentials, but it doesn't change anything. How to achieve that?