PowerShell Tutorial
Learn PowerShell step by step: 34 lessons in 8 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is PowerShell? Learn what PowerShell is, how it differs from classic shells, why it passes objects instead of text, and how Windows PowerShell 5.1 differs from PowerShell 7.
- Installing and Your First Commands Install PowerShell 7, choose between pwsh and powershell.exe, set up Windows Terminal or VS Code, and run first commands like Get-Date and Write-Output.
- Cmdlets and the Verb-Noun Pattern Understand PowerShell cmdlets: the approved Verb-Noun naming, Get-Command discovery, named and positional parameters, switch parameters and aliases.
- Getting Help Learn to teach yourself PowerShell: Get-Help with -Examples and -Full, Update-Help, reading syntax, Get-Member, about_ topics and Get-Command -Syntax.
Objects and the Pipeline
- Objects, Properties and Methods Learn how PowerShell objects work: .NET types, reading properties with dot notation, calling methods, static members, Get-Member and Select-Object -ExpandProperty.
- The Pipeline Understand the PowerShell pipeline: how the pipe passes objects one at a time, why it streams, which cmdlets block, and how ByValue and ByPropertyName binding work.
- Where-Object, Select-Object and Sort-Object Filter, reshape and sort objects in the PowerShell pipeline: Where-Object, Select-Object (-First, -Unique, calculated properties) and Sort-Object, with examples.
- Group-Object, Measure-Object and ForEach-Object Summarize objects in PowerShell: group and count with Group-Object, total and average with Measure-Object, and run code per object with ForEach-Object.
- Formatting and Output Control how PowerShell shows and saves objects: Format-Table, Format-List, Out-String, Out-File and Export-Csv, and why formatting must always come last.
Language Basics
- Variables and Types Learn PowerShell variables: $name syntax, strong typing with [int] and [string], type accelerators, casting rules, automatic variables, scopes and $null.
- Strings, Quoting and Here-Strings Master PowerShell strings: single vs double quotes, $() subexpressions, backtick escapes, here-strings, the -f format operator, and -join / -split with regex.
- Operators and Comparison Learn PowerShell comparison operators -eq, -like, -match, -contains and -in, case sensitivity, array-on-the-left filtering, logical operators, ternary and ??.
- Arrays and Hashtables Learn PowerShell arrays and hashtables: ranges, indexing, why += is slow, List[T], ordered hashtables, key lookup and a first look at splatting.
- Conditionals and Loops Learn PowerShell control flow: if and elseif, truthiness, switch with wildcards and regex, foreach, for, while, do loops, break, continue and labels.
Functions and Scripts
- Functions and Parameters Write PowerShell functions with param blocks, defaults, typed and switch parameters, and learn why return is not the only way a function gives output.
- Advanced Functions Turn PowerShell functions into cmdlet-like tools with CmdletBinding, mandatory and validated parameters, pipeline input, begin/process/end and -WhatIf.
- Scripts and Execution Policy Learn to save PowerShell code as .ps1 scripts, run them with the call operator, dot source libraries, use $PSScriptRoot, and understand execution policy.
- Modules and Profiles Learn how PowerShell modules are found, imported and installed from the Gallery, how to write a simple .psm1 module, and how to customize $PROFILE.
Files, Data and Errors
- Working with Files and Folders Learn how PowerShell works with files and folders: providers, Get-ChildItem, Copy-Item, Move-Item, Remove-Item, Test-Path, Get-Content and Set-Content.
- CSV, JSON and XML Read and write structured data in PowerShell with Import-Csv, Export-Csv, ConvertFrom-Json, ConvertTo-Json -Depth and Select-Xml, and avoid the common traps.
- Errors, try/catch and ErrorAction Understand PowerShell terminating and non-terminating errors, -ErrorAction, $ErrorActionPreference, try/catch/finally and the $Error list, with runnable models.
- Regular Expressions and Text Processing Use regular expressions in PowerShell: the -match and -replace operators, the $Matches variable, Select-String, named groups and [regex]::Matches for log files.
Real-World Use
- Processes, Services and the System Manage processes, services, event logs and scheduled tasks with PowerShell: Get-Process, Stop-Process, Get-Service, Get-WinEvent and Get-CimInstance explained.
- Remoting, Jobs and Parallelism Run PowerShell on other machines with Enter-PSSession, Invoke-Command and SSH, and run work in the background with Start-Job, thread jobs and ForEach-Object -Parallel.
- Web Requests and REST APIs Call web APIs from PowerShell: Invoke-RestMethod vs Invoke-WebRequest, headers, JSON bodies, bearer tokens, error handling, pagination and retry with backoff.
- Security and Secrets Write safer PowerShell: what SecureString really protects, SecretManagement, least privilege, constrained language mode, script block logging and injection pitfalls.
- Testing and Style with Pester Test PowerShell with Pester 5: Describe, It, Should, BeforeAll, mocks and TestDrive, then lint with PSScriptAnalyzer and follow naming and style conventions.
Projects
- Project: Disk and Folder Report Build a disk and folder report in PowerShell: scan files, group by extension, bucket by size, sort, format readable sizes and export to CSV. Includes a runnable JS model.
- Project: Log Analyzer Build a log analyzer in PowerShell: parse lines with a named-group regex, count by level, find the top repeated errors and return one summary object. Python stand-in included.
- Project: File Organizer Build a safe file organizer in PowerShell: classify files by extension, preview with -WhatIf, handle name collisions and keep an undo log. Includes a virtual file system model.
- Project: Bulk User Report from CSV Build a PowerShell report from a CSV of users: import, validate rows, collect rejects, add calculated properties, then write JSON and HTML output.
Practice and Review
- Practice Exercises with Solutions Twelve graded PowerShell exercises on the pipeline, functions, errors and files, each with a read-only PowerShell solution and a runnable JavaScript equivalent.
- PowerShell Interview Questions 26 PowerShell interview questions with short answers: objects, the pipeline, errors, scope, functions, remoting, jobs and security, with two runnable stand-ins.
- PowerShell Cheat Sheet A one-page PowerShell cheat sheet: syntax, operators, quoting, collections, common cmdlets, errors, remoting and a table of the pitfalls that catch everyone.