PowerShell Tutorial

Learn PowerShell 7 and Windows PowerShell: cmdlets, the object pipeline, scripting, error handling, CSV/JSON/XML, REST APIs, parallelism, and real automation scripts.

PowerShell is Microsoft's cross-platform shell and scripting language. Instead of passing text between commands, it passes objects — which is why a one-line PowerShell pipeline can do what takes a page of text parsing elsewhere. It is the standard tool for Windows administration, Microsoft 365 and Azure automation, and increasingly for cross-platform scripting on Linux and macOS.

This path covers installing PowerShell 7 alongside Windows PowerShell 5.1, discovering commands with the help system, and the object pipeline that everything else builds on. You then learn the language properly — types, operators, collections, control flow, functions, modules and error handling — before applying it to files, structured data, regular expressions, web APIs, background jobs and complete real-world scripts. Differences between PowerShell 7 and Windows PowerShell 5.1 are called out wherever they matter.

What You'll Learn

  • Getting Started
  • Core Concepts
  • Scripting
  • Working with Data
  • Automation in Practice

20 tutorials · Beginner to advanced · Exercises with solutions in every article · Free, no sign-up

Start here

Introduction to PowerShell

What PowerShell is, why it passes objects instead of text, how Windows PowerShell 5.1 differs from PowerShell 7, and the first commands worth knowing, all with real output.

Section 1. Getting Started

Start here to learn the PowerShell basics.

  • —Introduction to PowerShell – What PowerShell is, why it passes objects instead of text, how Windows PowerShell 5.1 differs from PowerShell 7, and the first commands worth knowing, all with real output.
  • —Installing PowerShell 7 and Setting Up Your Environment – Install PowerShell 7 on Windows, macOS or Linux next to Windows PowerShell 5.1, then set up a terminal, VS Code, a useful profile, execution policy and PSReadLine.
  • —Cmdlets, Parameters, and the Help System – Find any PowerShell command with Get-Command, read its syntax and help, use named, positional and switch parameters, and preview changes safely with -WhatIf and -Confirm.

Section 2. Core Concepts

  • —The Object Pipeline – How objects flow through the PowerShell pipeline: filter, select, sort, group and measure them, keep formatting last, export results, and understand parameter binding and streaming.
  • —Variables and Data Types – PowerShell variables, strings, numbers, booleans, $null, casting and type constraints, automatic and environment variables, and dates, with the conversion traps that cause real bugs.
  • —Comparison, Logical, and Arithmetic Operators – How PowerShell's arithmetic, comparison, logical and type operators really behave, including collection filtering, $null placement and string-versus-number traps.
  • —String Formatting, Split, Join, Replace, and Other Operators – The PowerShell operators for building and taking apart text (-f, -split, -join, -replace) plus ternary, null-coalescing, chaining, call, splatting and redirection.
  • —Arrays, Hashtables, and Custom Objects – Arrays, generic lists, hashtables and [PSCustomObject] in PowerShell: indexing, the += performance trap, iteration, CSV and JSON export, and Compare-Object.
  • —Providers, Drives, Aliases, and Native Commands – How PowerShell aliases differ across platforms, how providers expose the environment, registry and certificates as drives, and how to run native programs safely.

Section 3. Scripting

  • —Conditionals: if, switch, and the Ternary Operator – Making decisions in PowerShell scripts with if, elseif, switch and the ternary operator, including truthiness traps, switch's matching modes and guard clauses.
  • —Loops and Iteration – How PowerShell's foreach, ForEach-Object, .ForEach(), for, while and do loops differ, with measured timings, labels, hashtable iteration and retry loops.
  • —Functions and Advanced Functions – Write PowerShell functions that behave like real cmdlets: typed and validated parameters, pipeline input, -WhatIf and -Confirm support, and help that Get-Help can show.
  • —Scripts, Scope, and Modules – Turn PowerShell functions into scripts and versioned modules: param blocks, $PSScriptRoot, scopes and dot-sourcing, manifests, autoloading and the PowerShell Gallery.
  • —Error Handling – How PowerShell errors really work, from terminating and non-terminating errors to try/catch/finally and native exit codes, plus a robust pattern for scripts that run unattended.

Section 4. Working with Data

  • —Working with Files and Folders – Find, create, copy, move, read, write, archive, hash and watch files in PowerShell, including the -Filter vs -Include trap and the encoding change between 5.1 and 7.
  • —CSV, JSON, and XML – Read, convert, and write CSV, JSON, and XML in PowerShell, including the type, depth, delimiter, and encoding traps that silently corrupt real data.
  • —Regular Expressions – Match, extract, and replace text with .NET regular expressions in PowerShell: -match, -replace, Select-String and [regex], tested on real log files.

Section 5. Automation in Practice

  • —Calling REST APIs and Web Requests – Call REST APIs from PowerShell with Invoke-RestMethod: query strings, bearer tokens, JSON bodies, status codes, pagination, retries, timeouts and file downloads.
  • —Remoting, Background Jobs, and Parallelism – Run PowerShell work in the background with jobs, in parallel with thread jobs and ForEach-Object -Parallel, and on other machines over WinRM or SSH remoting.
  • —Real-World PowerShell Scripts – Build a disk usage report, a safe old-file cleanup and an API health monitor in PowerShell, then schedule them with Task Scheduler, cron or a systemd timer.