Scheduled jobs do something based on a trigger. We are able to configure scheduled jobs with the graphical user interface or – from my point of view – much easier and faster with PowerShell. In this blog post I will give you an example on how you can quickly create a scheduled job for your PowerShell script.
Open PowerShell ISE or VS Code. Copy the code below into your session and edit it at as you like.
Notice: This example code creates a scheduled job with the name PingC and a script located at c:\temp. Furthermore, a trigger is used that begins instantly and repeats every 15 minutes indefinitely.
Register-ScheduledJob -Name PingDC -FilePath "C:\Temp\script.ps1" ` -Trigger (New-JobTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 15) ` -RepeatIndefinitely)
Thank you for reading this article.