Marc
Marc

Reputation: 19

Remote starting a scheduled task powershell code

Dear readers,

As an IT Trainee I need to write a powershell script for remote starting a scheduled task on a server. I have done lots and lots of research, but I can't seem to find an explanation of the exact thing that I want to do.

What I want is a powershell script that logs me in onto the server, and from there starts the scheduled task with me only filling in my password. This is because logging into the server and starting it from there will take up too much time.

What I have right now is this line of code:

Enter-PSSession -ComputerName ..... -Authentication Kerberos -Credential ..... -EnableNetworkAccess -Port ....

Start-ScheduledTask  -Taskpath \\....\..\.....\......\Tasks -Taskname azure ad sync scheduler

I have put dots on some of the more vulnerable places for security reasons, I hope and think that it won't influence any answers

Hopefully someone can help me or redirect me to a good source of information.

Kind regards,

Marc

Upvotes: 0

Views: 3773

Answers (1)

Farhad Farahi
Farhad Farahi

Reputation: 39267

Use the following:

Start-ScheduledTask -Taskpath "\\....\..\.....\......\Tasks" -Taskname "azure ad sync scheduler"

Note the double quotes.

Upvotes: 1

Related Questions