PowerShell Hands-On Exercises Primer 3
In this lab, you'll learn advanced PowerShell techniques and utilities. You will start by mastering importing and processing external XML files to generate comprehensive reports. Moving forward, you'll create a reusable script that leverages WMI and CIM instances to retrieve system information from client workstations. As you delve deeper, you'll automate the creation of new users in Active Directory, using cmdlets that streamline this essential administrative function. Your journey will then take you to monitoring, where you'll write scripts to check the status of specific services on a Windows Server, and to sift through Windows Event Logs to report on failed login attempts—an essential aspect of security management. Finally, you'll use PowerShell remoting techniques to retrieve the list of installed software on distant machines. When you have finished, you'll have the skills to craft complex PowerShell scripts that utilize these advanced techniques and utilities, greatly enhancing system administration and monitoring.
Terms and conditions apply.
Lab info
Lab author
Challenge
Get Started in the Lab Environment
Here are the initial instructions and explanation of the lab environment. Read this while your environment is busy creating itself from nothing. Yes, this violates physics; we know. How fun!
Challenge
Import and Process an External XML File
To start the lab, you will process XML data using PowerShell. Firstly, we will learn how to import XML files into PowerShell, and set the foundation for data processing. As you move forward, you will adapt PowerShell commands to extract relevant information from the XML content. Finally, you will put your skills to the ultimate test by converting the processed XML data into a detailed HTML report. By the end of this challenge, you will be able to work with XML data, transforming and reporting it using PowerShell.
Challenge
Create a Reusable Script to Retrieve System Information
This challenge will teach you to retrieve system metrics from memory, CPU utilization, OS details, and processes. You will create a script in PowerShell that seamlessly extracts this information. By the challenge's conclusion, you will have created a script ensuring you have a comprehensive snapshot of crucial system metrics when needed.
Challenge
Automate the Process of Creating New Users in Active Directory
You will learn how to automate the creation of new users in Active Directory using PowerShell. You will start by getting familiar with the Active Directory module in PowerShell, and its user management cmdlets. After that, you will develop a script to automate the user creation process, and ensure you accurately capture all the necessary attributes and details. Finally, you will integrate validation processes to verify the successful addition of users.
Challenge
Check the Status of Specific Services
You will be guided through monitoring services on a Windows server, breaking it into several critical stages. Firstly, you will gain an understanding of how Windows services work, which will be the foundation for performing automated health checks. Following that, you will create a script that will periodically check the status of specific services to ensure that they are always operational. If any of these services fail, your script will try to revive them and notify the designated administrator. By the end of this challenge, you will have gained the necessary skills to independently monitor, recover, and report any service interruptions on a Windows server.
Challenge
Review the Windows Event Logs
You will now delve into the Event Logs, focusing specifically on a 24-hour time span. The primary objective is to identify any failed login attempts, a task of significant importance in system security. Once identified, you will create a report grouping these attempts based on user accounts and their respective source IP. It not only aids in identifying potential threats but also helps trace back the source of these attempts. After this challenge, you'll have the skill set to effectively monitor, analyze, and report critical data from Windows Event Logs.
Challenge
Retrieve Installed Software on a Remote Machine
To finish up this lab, you will establish a secure remote connection to a workstation using PowerShell. After establishing a connection, you can retrieve a thorough list of installed software. Once done, the final step involves comparing and reporting. It means checking the list of retrieved software against a pre-approved list, and flagging any unauthorized applications. By completing this challenge, you'll gain the expertise to effectively monitor software compliance across a network using PowerShell.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.
Recommended prerequisites
- Windows Server 2022. Similar, for this lab, to Windows Client (Windows 10/11)
- PowerShell 7.x
- Visual Studio Code
- PowerShell Extension for VS Code
- Administrative privileges