Learn PowerShell

Cross-platform object-based shell and scripting language from Microsoft

18 lessons · 3 hours · 4 levels · covers PowerShell 7.5

PowerShell is a shell and scripting language built on .NET in which commands (cmdlets) pass structured objects through the pipeline instead of text. It is the standard automation tool for Windows, Active Directory, Microsoft 365 and Azure, and PowerShell 7 runs on Windows, Linux and macOS. Learning it lets you script system administration and cloud tasks with real data types, error handling and modules.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics6 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms11 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs15 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know18 lessons · 3 hours in total

The PowerShell tree

PowerShellCmdlets, Get-Help and Get-CommandCmdlets, Get-Helpand Get-CommandObjects in the pipelineObjects in thepipelineVariables, types and stringsVariables, types andstringsFilter, sort and selectFilter, sort and selectFiles, paths and providersFiles, paths andprovidersOperators, if, switch and loopsOperators, if, switchand loopsArrays and hashtablesArrays andhashtablesFunctions and parametersFunctions andparametersScripts, execution policy and profilesScripts, executionpolicy and profilesOutput, formatting and Write-HostOutput, formattingand Write-HostCustom objects, JSON and CSVCustom objects,JSON and CSV
Essentials and Practical shown (11 of 18 lessons); the full list is below. Click a lesson to read it.

All 18 lessons, in order

Getting started

  1. Cmdlets, Get-Help and Get-Command · Essentials · 8 min

    How PowerShell commands are named, how to discover them and how to read their help.

  2. Files, paths and providers · Essentials · 10 min

    Navigate, read, write, copy and delete files, build paths safely and use drives such as Env:.

Objects and the pipeline

  1. Objects in the pipeline · Essentials · 10 min

    PowerShell pipes .NET objects with properties and methods, not text; Get-Member shows what they contain.

  2. Filter, sort and select · Essentials · 12 min

    Shape pipeline output with Where-Object, Sort-Object, Select-Object, Group-Object and Measure-Object.

  3. Output, formatting and Write-Host · Practical · 10 min

    Know the difference between output and display: Write-Output, Write-Host, Write-Verbose, Format-* and Out-*.

Language essentials

  1. Variables, types and strings · Essentials · 10 min

    Store values in $variables, understand type conversion and expand variables in double-quoted strings.

  2. Operators, if, switch and loops · Essentials · 12 min

    Compare with -eq, -like and -match, branch with if and switch, and loop with foreach, for and while.

Working with data

  1. Arrays and hashtables · Practical · 12 min

    Create and use arrays, generic lists, hashtables and ordered dictionaries.

  2. Custom objects, JSON and CSV · Practical · 12 min

    Create [pscustomobject] records and move data in and out of JSON, CSV and REST APIs.

Functions and scripts

  1. Functions and parameters · Practical · 12 min

    Write functions with typed, mandatory, validated and switch parameters, and call them the PowerShell way.

  2. Scripts, execution policy and profiles · Practical · 10 min

    Write .ps1 scripts with a param block, run them on any OS, and understand execution policy, dot-sourcing and $PROFILE.

  3. Error handling: try/catch and -ErrorAction · Advanced · 12 min

    Terminating vs non-terminating errors, -ErrorAction Stop, try/catch/finally, $ErrorActionPreference and native exit codes.

  4. Advanced functions and pipeline input · Advanced · 14 min

    Use [CmdletBinding()], begin/process/end blocks and ValueFromPipeline to write functions that act like real cmdlets.

  5. Modules and the PowerShell Gallery · Advanced · 12 min

    Install modules from the PowerShell Gallery and package your own functions as a module with a manifest.

Advanced and internals

  1. Jobs, parallelism and remoting · Advanced · 12 min

    Run work concurrently with Start-ThreadJob and ForEach-Object -Parallel, and on other machines with Invoke-Command.

  2. Using .NET and PowerShell classes · Expert · 14 min

    Call any .NET API with [Type]::Method(), create objects with ::new(), define PowerShell classes and compile C# with Add-Type.

  3. Output semantics, unrolling and streams · Expert · 14 min

    Why functions return extra values, how collections unroll in the pipeline, and how the six output streams are redirected.

  4. Scopes, dot-sourcing and performance · Expert · 12 min

    How variable scopes work, what $script: and $global: change, and the patterns that make PowerShell code fast.