Schedule Tasks Using Windows PowerShell
In this virtual IT Pro Challenge, learners gain first-hand knowledge of creating a Windows PowerShell script routine and scheduling, managing, and deleting it as a task. Scripting and task management skills benefit Network Operations Specialists, System Administrators, and Network Engineers in effectively maintaining a large number of servers.
This hands-on experience will teach you how to create and supervise scheduled automated tasks in Windows PowerShell on a virtual lab machine (VM). To use the VM on an Apple system, Microsoft Remote Desk will need to configure your environment. When your VM setup completes, you will use Powershell ISE to create a cleanup script and Powershell as an Administrator to enter scheduled task cmdlets. You will also use Task Scheduler Library, a Windows Computer Manager GUI, to verify that your task has run. Then you will remove a scheduled task.
Beginners who have worked with Microsoft Windows OS and its command-line interface will be ready to complete the virtual lab successfully. This guided challenge runs 30-45 min, to finish in one sitting. Participants will not be able to pause the lab and return to their work. Learners connect to the VM, provisioned on Azure, through a remote desktop protocol (RDP) file. Apple computers need to use Windows Remote Desktop to open the file.
Writing, running, and managing PowerShell scripts represents fundamental information technology skills for Network Operations Specialists, System Administrators, Network Engineers. These roles need to develop and deploy automated maintenance scripts onto a large number of servers or machines. Also, technicians benefit from this lab in learning how the automated scripts they run, through PowerShell, work. Software testers advance from this lab by honing their PowerShell scripting techniques, which are valuable in checking hardware drivers on multiple devices.
Understanding the Scenario:
You are a system administrator for a company that needs to perform automated maintenance on a large number of servers by using scripts. To do this, you do a proof of concept scheduling and managing tasks on a single server in preparation to run several Windows PowerShell scripts on a routine basis. You use Windows PowerShell to create a script for a scheduled task. Next, you create a scheduled task and then use Windows PowerShell to manage a scheduled task.
Configure Your Environment:
You sign in to an Azure server, provided as part of the lab. Then, you verify your VM has the state of running. You connect through RDP and sign into a windows VM environment. After launching PowerShell as an administrator, you make a folder for your lab work and go to that directory. To ensure access to your VM, it must complete provisioning. Once you have finished preparing your environment, you can move onto the next lab exercises.
Create a Script for a Scheduled Task:
This lab exercise has two parts. First, you create a cleanup script in Windows PowerShell ISE, that deletes extra files. You save this algorithm for later use. Second, you create ten sample files with a .tmp extension, in PowerShell, to use in the next sections of the lab. You verify that the ten files have been created by viewing the class folder directory.
Create a Scheduled Task:
In this lab, you use PowerShell to create variables holding a scheduled task action, principal, and trigger. You then create a new scheduled task combining the action, principal, and trigger. Finally, you register the scheduled task. You open the Task Scheduler Library from the computer manager to check the successful creation of the scheduled task.
Scheduled tasks in PowerShell have a significant advantage over creating a scheduled job. You can run any code or commands, even something not initially created on PowerShell, through a scheduled task. Scheduled jobs, on the other hand, require PowerShell script or command only.
Manage a Scheduled Task:
You use the Task Scheduler Library and Powershell to view the scheduled task’s status. You learn how to look at the “Last Run Result” in checking if a task has not run, runs, or has completed. You get information about TaskPath, TaskName, and State when you research the task status in Power Shell. After the scheduled task has run, you delete the scheduled task and view the log created from the scheduled task.
Congratulations! You have completed the lab and mastered scheduling tasks, including managing and deleting them. You can:
- Create a script for a scheduled task.
- Create a scheduled task.
- Manage a scheduled task.
You can apply this PowerShell task scheduling capability to one or many machines and enhance your automated testing capabilities.
See the full benefits of our immersive learning experience with interactive courses and guided career paths.
The Windows PowerShell Getting Started Lab from Learn on Demand introduces the student to working ...
In this IT Pro Challenges virtual lab, learners are introduced to skills required to manage ...