PowerShell
Microsoft's powerful automation shell β the essential tool for Windows administrators, Azure DevOps engineers and anyone managing Microsoft infrastructure. Now cross-platform and open source.

Quick facts
What is PowerShell?
The automation shell built on .NET
PowerShell was created by Microsoft engineer Jeffrey Snover and released in 2006. It was designed to fix the fundamental weakness of CMD β working with plain text. PowerShell works with .NET objects instead, making it far more powerful and consistent.
Every PowerShell command (called a cmdlet) follows a Verb-Noun naming convention: Get-Process, Set-Location, New-Item. This makes commands predictable β you can often guess the right command before looking it up.
The pipeline is PowerShell's superpower. Connect commands with | and the output flows as structured objects β not text strings. Filter, sort and format thousands of objects with a single line.
PowerShell Core (version 6+) is now fully cross-platform β it runs on Windows, Linux and macOS and is completely open source on GitHub. It integrates deeply with Azure, Microsoft 365, Active Directory and Windows Server.
What you will learn
- 1Variables with $ prefix and data types
- 2Write-Host, Write-Output and formatting
- 3Cmdlets β Verb-Noun naming convention
- 4Pipeline β passing objects between commands
- 5Control flow β if, switch, foreach, while
- 6Functions with parameters and defaults
- 7Working with files and folders
- 8String manipulation and -f formatting
- 9Arrays and hashtables
- 10Error handling with try/catch
Taste of PowerShell
Your first PowerShell script
PowerShell variables always start with $. String interpolation works in double quotes. Notice how the pipeline filters and formats objects in one clean chain.
Reference
PowerShell Command Reference
The most important PowerShell syntax and cmdlets at a glance. Bookmark this section.
$name = "Alice"Declare a variable β all variables start with $$num = 42Integer variableWrite-Host "text"Print to screen (console output)Write-Output $varSend output down the pipeline"Hello, $name!"String interpolation in double quotes"Sum: $($a + $b)"Expression interpolation with $()Get-ChildItemList files and folders (like ls or dir)Set-Location "C:\path"Change directory (like cd)Get-Content "file.txt"Read a file line by lineSet-Content "file.txt"Write content to a fileAdd-Content "file.txt"Append content to a fileif ($x -gt 0) { }If condition β use -gt not >-eq -ne -gt -lt -ge -leComparison operators (equal, not equal, etc.)-and -or -notLogical operatorsforeach ($x in $arr) { }Loop over each item in a collectionfor ($i=0; $i -lt 5; $i++)C-style for loopwhile ($x -gt 0) { }While loopfunction Get-Greeting { }Function definition β Verb-Noun namingparam($Name, $Age = 18)Function parameters with default value@("a", "b", "c")Create an array@{Key = "Value"}Create a hashtable (key-value pairs)$arr | Where-Object { }Filter objects in the pipeline$arr | ForEach-Object { }Process each object in pipelinetry { } catch { }Error handling# commentSingle-line commentFAQ
Common questions about PowerShell
What is PowerShell used for?
PowerShell is used for automating repetitive tasks on Windows systems and cloud infrastructure. Common uses include managing Active Directory user accounts, automating Azure resources, bulk file operations, scheduled maintenance tasks, deploying software across multiple machines, configuring Windows Server, and managing Microsoft 365 (Exchange, SharePoint, Teams). IT administrators and DevOps engineers use it daily.
What is the difference between PowerShell and CMD (Command Prompt)?
CMD is the old Windows command line from the 1980s β it works with plain text output and has very limited scripting. PowerShell is a modern shell built on .NET that works with objects, not text. When you run Get-Process in PowerShell, you get actual process objects with properties you can filter and sort β not just a text blob. PowerShell is far more powerful and is the recommended tool for Windows automation.
Does PowerShell work on Linux and macOS?
Yes. PowerShell Core (version 6+) is fully cross-platform and runs on Linux, macOS and Windows. It is open source and maintained by Microsoft on GitHub. You can install it on Ubuntu, Debian, CentOS, macOS and more. However, Windows-specific cmdlets (like those for Active Directory or Windows Registry) only work on Windows.
What is the pipeline in PowerShell?
The pipeline (|) passes the output of one command as input to the next β but instead of passing text like Bash, PowerShell passes full .NET objects. This means the receiving command gets structured data with properties and methods, not a string to parse. For example: Get-Process | Where-Object { $_.CPU -gt 100 } | Sort-Object CPU gets all processes, filters those using more than 100 CPU seconds, and sorts them β all in one line.
What is the Verb-Noun naming convention?
All PowerShell cmdlets follow a Verb-Noun pattern: Get-Process, Set-Location, Remove-Item, New-Item. This makes commands predictable and self-documenting. The verbs are standardised (Get, Set, New, Remove, Start, Stop, Test, Invoke, etc.) so you can often guess a command name. Run Get-Verb to see all approved verbs.
Should I learn PowerShell or Bash?
Learn both for a complete automation skill set, but prioritise based on your environment. If you work in Windows or Microsoft cloud (Azure, Microsoft 365, Active Directory), start with PowerShell. If you work in Linux, cloud servers (AWS, GCP) or CI/CD pipelines, start with Bash. PowerShell is available on Linux too, but Bash is the native shell there.
Ready to automate with PowerShell?
10 beginner-friendly examples covering variables, pipelines, loops, functions and file automation. Each shows the exact output.
Start the PowerShell tutorial βThe Story of PowerShell
Real history, real companies, and an honest look at where PowerShellshines and where it doesn't β not just a feature list.
Where it came from
Microsoft released PowerShell in 2006, led by Jeffrey Snover, designed to fix a long-standing gap in Windows: unlike Unix, Windows never had a genuinely powerful scripting shell built in. PowerShell's key innovation was passing structured objects between commands instead of plain text (which Bash and Unix shells do), making it easier to reliably extract specific data from command output.
How itβs actually used today
PowerShell is the standard tool for Windows server administration and, increasingly, for managing Microsoft's Azure cloud platform β IT departments use it to manage user accounts across an entire organisation via Active Directory, and DevOps engineers use it in automation pipelines for Windows-based infrastructure specifically.
Strengths & trade-offs
Passing structured objects between commands (rather than plain text like Bash) makes PowerShell genuinely more reliable for complex automation, since you're not parsing text output and hoping the format doesn't change. Its trade-off is that it's historically been Windows-specific, though Microsoft has offered a cross-platform version (PowerShell Core) since 2016 to address exactly that limitation.
What to learn next
For anyone working across both Windows and Linux infrastructure, learning Bash alongside PowerShell is genuinely useful β the underlying concepts (piping, variables, control flow) transfer, even though the syntax and philosophy differ. Azure-specific automation is the natural specialisation for PowerShell in cloud-focused roles.