PowerShell

Microsoft's cross-platform shell for automating Windows, Linux and macOS.

PowerShell is Microsoft's shell and scripting language, and it runs on Windows, Linux and macOS. Unlike Bash, which passes text between commands, PowerShell passes objects, so you read properties instead of parsing output.

  • Beginner
  • 8 lessons
Not started yet
Start lesson 1

Lessons

  1. Your First ScriptWrite and run your first .ps1 script, and learn the main idea behind PowerShell: commands pass objects, not just text.
  2. Variables & TypesLearn how PowerShell variables work and the types you will use most: numbers, strings, arrays and hashtables. A variable can hold any .NET type, including objects returned by cmdlets.
  3. Control FlowLearn if statements, loops and switch. PowerShell's comparison operators look different from most languages, and switch can match wildcards and regular expressions.
  4. Functions & CmdletsLearn to write functions with named parameters, validation, help text and pipeline input, so they behave like built-in cmdlets.
  5. Working with ObjectsLearn to filter, sort and select objects in the pipeline. Because commands return objects, you read properties directly instead of parsing text.
  6. Files & the FilesystemLearn to navigate folders and read, write, copy and delete files, including JSON and CSV. The same commands also work on network paths and registry keys.
  7. Mini Project: System Info ScriptPut the earlier lessons together in a script that gathers system information and prints a formatted report.
  8. PowerShell CheatsheetCmdlets, objects, and scripting syntax on one page.

Install it on your own computer

Windows includes PowerShell 5.1. For these lessons, install PowerShell 7 or later, which runs on Windows, macOS and Linux.

Bash
# PowerShell 5.1 is built in — press Win+X, select "Terminal"
# For PowerShell 7+ (recommended):
winget install Microsoft.PowerShell

# Or download from:
# github.com/PowerShell/PowerShell/releases

# Check version:
$PSVersionTable.PSVersion

# Set execution policy to allow local scripts:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

What people build with PowerShell

Learn the basics first, then pick up these tools when a project needs them.

Practical uses

  • Administer Windows and Microsoft cloud services
  • Automate structured system tasks
  • Manage Active Directory and Microsoft 365
  • Build cross-platform DevOps scripts

Projects to try

  1. System inventory report
  2. Bulk user provisioner
  3. Azure cleanup tool
  4. CI environment diagnostic module

Common tools and packages

PesterPSReadLinePowerShellGetAzMicrosoft.GraphdbatoolsPSScriptAnalyzerposh-git

Well-known software

Windows administration scriptsAzure Cloud ShellMicrosoft 365 automationChocolatey toolingPowerShell itselfDevOps build agents