Implement a Windows PowerShell Workflow
This IT Pro Challenge virtual lab teaches learners how to construct and run a Windows PowerShell Workflow to automate maintenance, which takes a few minutes to run on multiple servers. Lab exercises how to analyze and convert PowerShell scripts to be effective as System Administrators, Network Operations Specialists, and Network Engineers.
This 45-minute virtual lab instructs learners to analyze a Windows Powershell script created for system maintenance and convert and run it as a workflow. Beginners who have worked in Microsoft Windows operating systems and some familiarity in the Windows PowerShell command-line receive guidance scripting and understanding WindowsPowershell commands. Knowing how to open the PowerShell ISE scripting pane proves most helpful to know before starting this hands-on experience.
Understanding the Scenario:
In this guided lab, you are a system administrator for your organization. You manage several hundred servers, and it is becoming increasingly difficult to complete certain maintenance activities in a reasonable amount of time. Your current approach is to run a script that processes each server one at a time. Each server takes several minutes to perform the actions before the script can continue to the next server. To shorten this maintenance time, you plan to use the Windows PowerShell Workflow to perform the maintenance activities.
Configure Your Environment:
In this section, you set up the lab. You log onto an Azure server and then connect to a virtual machine. If you have a Mac, install Microsoft Remote Desktop to run the lab VM instance. Be sure your LabVM has the status of “Running,” listed in Microsoft Azure before connecting to it. The configuration can take five to ten minutes, and you receive a notification when setup completes. You can also find your virtual machine status on the virtual machine overview page in Azure.
Analyze the Current Script:
The steps in this lab exercise present a simple Maintenance.ps1 script. The code takes a few minutes to remove temporary files, get event logs, and find computer services in progress. The computer outputs script results in two different logs. You put this algorithm into Powershell ISE and run it through the command line. Then you confirm log contents.
If the system has no errors in the event.log, then an empty or nonexistent log results after running the Windows PowerShell program. At the end of this section, you see PowerShell command options and parameters to remove, write, and get server data. Also, you experience how running the maintenance script for many servers spends lots of time.
Convert the Script into a Workflow:
Learners transform the original script, from the previous exercise, into a workflow. PowerShell Workflows that sequence different steps so they can run in parallel across multiple machines. They use the “inlinescript” command to run a subset of actions to be performed locally on another computer, returning the results to the workflow in the process.
The parallel command with sequence commands executes each statement together. So one part of the sequence can start while another section of the sequence runs or finishes on another machine. Lab participants also learn how to use a variable in each write command so that the system administrator knows which computer goes with which logs.
At the end of the conversion, the script has a command block outside of the inline script and two command blocks that run within the workflow. The learner sees the reason for this setup in the next lab portion.
Run the Workflow:
You see a different way to run the workflow by right-clicking code to select and then choosing to execute it. Then you run the workflow using the PowerShell command-line. As the script executes, the command block outside the inline script finishes slower than the other inline blocks running in parallel. This result provides helpful feedback in streamlining and sequencing maintenance tasks through PowerShell.
At this lab challenge’s conclusion, learners understand how to construct a workflow that runs across hundreds of machines simultaneously. The learner grasps this PowerShell workflow concept by running lab exercises:
- Analyzing a script.
- Converting the script into a workflow.
- Running the workflow.