An Introduction to Powershell
Author(s): Byrch
Last Updated: 07-30-2025
Recommended Prerequisites (click to expand)
None
What is PowerShell?
PowerShell is a cross-platform task automation solution made up of a command-line shell, a scripting language, and a configuration management framework. PowerShell runs on Windows, Linux, and macOS.
Why it's important
Powershell is important due to the nature of the competition. You are tasked with securing systems in a timely manner, while also being compliant to industry best security practices. Powershell provides a fast way to automate security checks, apply patches, disable insecure configurations, and manage users.
- Powershell can run scripts to remediate the tedious, time consuming tasks
- It allows mass bulk changes, greatly improving productivity and time usage
- It's faster and more consistent than manually navigating through GUI
How to open/use PowerShell
On Windows (Recommended):
-
Press Start and type
Powershell -
Choose Windows Powershell or Powershell 7 (if installed)
-
To run with administrative privileges, right-click and select Run as Administrator
If the steps above do not work, try the solutions outlined in the Microsoft documentation: https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell
Syntax basics
Cmdlets: PowerShell commands follow the Verb-Noun naming convention.
Example:
Get-Service
Pipelines (|): Pass the output of one command into another.
Get-Service | Stop-Service
DO NOT run code blindly from the internet. Always assess the code and potential risks before executing it. For example, the code above will "get" all services and pipe them into the "stop" command, which might stop critical services and potentially damage the host or guest system.
Variables: Use $ to define variables.
$name = "CyberPatriot"
${this can also be a variable} = "CyberPatriot"
Scripts: Save commands in a .ps1 file and execute it:
.\script.ps1
Help:
Get-Help <command>
Helpful websites, forums, and communities
Unofficial CyberPatriot Community Discord (Recommended)