3

I want to schedule a task in task scheduler from Powershell. I want to set 2 trigger "On connection to user session" with local and remote both.

And also,I want to uncheck some settings and conditions in case if they are marked in task scheduler.
Can someone please tell me how to set above trigger and how to unchheck settings and conditions?

Thank You

1 Answers1

0

The only way i have found to accomplish that is by creating a new task using the UI. Then export the task to XML. Then use powershell command for creating a new task by importing the XML.

Register-ScheduledTask -Xml (Get-Content "your-exported.xml" | Out-String) -TaskName "some task name"

you can also add credentials to the command if needed, hence

Register-ScheduledTask -Xml (Get-Content "your-exported.xml" | Out-String) -TaskName "some task name" -User "domain\user" -Password "pa55w0rd"
posix99
  • 356
  • 3
  • 13