From the course: PowerShell: Automating Administration

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Schedule tasks

Schedule tasks - Server Tutorial

From the course: PowerShell: Automating Administration

Start my 1-month free trial

Schedule tasks

- [Instructor] In the previous video, we created a couple of jobs that could be run in the background. One updated the PowerShell help files, and the other generated a list of users whose passwords expire soon. If these processes are to be fully automated, they need to be configured to launch on their own. PowerShell has two different ways to do this. Neither one of them is done with a single expression, but in both cases, we need to define things, we need to specify a trigger and an action, and then we're going to need to register the schedule event. One way to do this is to schedule a task. So here on our workstation, let's go ahead and do that. The first thing we need to do is specify an action, and assign it to a variable. The action is the payload. That's the actual script or code that we want to run. So, I'm going to define a variable here. I will call it $RunScript, and I'm going to set it equal to New-ScheduledTaskAction, and the task that I want to accomplish is that I want…

Contents