Skip to main content

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.

  1. Powershell can run scripts to remediate the tedious, time consuming tasks
  2. It allows mass bulk changes, greatly improving productivity and time usage
  3. It's faster and more consistent than manually navigating through GUI

How to open/use PowerShell

On Windows (Recommended):

  1. Press Start and type Powershell

  2. Choose Windows Powershell or Powershell 7 (if installed)

  3. 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)

Microsoft Learn: PowerShell

PowerShell Gallery – Find and share PowerShell modules.

r/PowerShell (Reddit)

PowerShell Discord Community

Stack Overflow - PowerShell