martes, 27 de diciembre de 2022

WINDOWS. Register-ScheduledJob. Scheduled Task. Restart Server

 Purpose

Create a scheduled task to reboot one server

Information

This commnad don't need install 

Steps

Connect to server, open power shell windows and write:

COMMAND: 

Register-ScheduledJob Reinicio {Restart-Computer -Force} -Trigger (New-JobTrigger -At 22:00 -DaysOfWeek "Friday" -weekly) -ScheduledJobOption (New-ScheduledJobOption -RunElevated)

This command add to system one new task, you can verify and finished of planning opening scheduler task and...

Path: \Microsoft\Windows\PowerShell\ScheduledJobs


Change to SYSTEM user:


For delete task from Ps: Unregister-ScheduledJob Reinicio 



Other examples:

Daily

Register-ScheduledJob Reinicio {Restart-Computer -Force} -Trigger (New-JobTrigger -At 22:00 -Daily) -ScheduledJobOption (New-ScheduledJobOption -RunElevated)

 Weekly

Register-ScheduledJob Reinicio {Restart-Computer -Force} -Trigger (New-JobTrigger -At 22:00 -weekly) -ScheduledJobOption (New-ScheduledJobOption -RunElevated)

 Other option:



by GU | Published: December 27 2022 | Last Updated: January 9 2023

No hay comentarios: