1

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

enter image description here

I've also tried to remove supplying credentials, but it doesn't change anything. How to achieve that?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Dmitry Dorofeev
  • 85
  • 1
  • 1
  • 13
  • 2
    What do you mean by "but I can't options/setting to either create Task without 'Don't store password." – Jon Skeet Oct 28 '22 at 12:31
  • Sorry, it was a typo. I meant, that I can't find the way how to manage this Task setting via PowerShell. – Dmitry Dorofeev Oct 30 '22 at 20:45
  • 1
    It's still really unclear to me what you're trying to do and what's happening. You say you can't "set this options/setting" - *which* "options/setting"? What is stopping you from setting it? I have to say, this doesn't really sound like a programming question - it may be better for SuperUser... – Jon Skeet Oct 31 '22 at 07:09
  • I've edited my initial question. This is a programming question, but looks to be a tricky one. Also, tried to follow [this](https://stackoverflow.com/q/32727042/5148934) advise, but it didn't help. – Dmitry Dorofeev Oct 31 '22 at 08:01
  • Ah, it's *much* clearer now that you've shown what you mean. – Jon Skeet Oct 31 '22 at 08:03
  • Yeah, it's better to give as much details as possible, I know... – Dmitry Dorofeev Oct 31 '22 at 08:20
  • So, any ideas folks? – Dmitry Dorofeev Nov 01 '22 at 10:43

0 Answers0