Skip to content

PowerShell Introduction

Learn how PowerShell automates tasks with cmdlets, scripting, and a .NET-based framework for Windows, Linux, and macOS administration and DevOps workflows.

PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell, a scripting language, and an underlying .NET-based engine. It's designed to help administrators and developers automate tasks that would otherwise require manual, repetitive interaction with a graphical interface.

What is PowerShell?

PowerShell operates on three levels simultaneously:

  • A shell: an interactive command-line environment where you type commands (called cmdlets) to interact with the operating system.
  • A scripting language: a full-featured language with variables, loops, functions, and error handling for writing reusable .ps1 scripts.
  • A framework: built on the .NET Common Language Runtime (CLR), giving it access to the entire .NET class library and allowing deep integration with Windows and other systems.

Unlike traditional shells that only understand text, PowerShell commands (called cmdlets, pronounced "command-lets") follow a consistent Verb-Noun naming pattern, such as Get-Process, Stop-Service, or New-Item. This predictable naming makes the language highly discoverable. Once you learn the pattern, you can often guess the correct cmdlet name.

Consolepowershell
Get-Process -Name "notepad"
Outputplaintext
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    520      30    10096      37888       8.20   5744   1 notepad

History and Evolution

PowerShell was first released in 2006 as Windows PowerShell, intended to replace the aging Command Prompt (cmd.exe) and .bat scripting for serious system administration work. It was built entirely on the .NET Framework, giving it object-oriented capabilities far beyond what Batch scripting could offer.

Key milestones:

  • 2006: Windows PowerShell 1.0 released, Windows-only, built on .NET Framework.
  • 2016: PowerShell Core 6 released as open-source, built on .NET Core, introducing cross-platform support for Windows, Linux, and macOS.
  • 2020-present: PowerShell 7+ unifies the feature set of Windows PowerShell and PowerShell Core, becoming the recommended version for all new development.

Windows PowerShell vs PowerShell 7 (Core)

Aspect Windows PowerShell PowerShell 7 (Core)
Versions 1.0 - 5.1 6.0+
Built on .NET Framework .NET (Core/5+)
Platform Windows only Windows, Linux, macOS
Installation Pre-installed on Windows Separate download/install
Executable name powershell.exe pwsh.exe
Development status Maintenance mode (no new features) Actively developed
Module compatibility Full legacy module support Most modules supported; some legacy Windows-only modules need compatibility mode

The Key Differentiator: Object-Based Pipeline

The single most important concept that separates PowerShell from Batch and Bash is how it passes data through the pipeline (|).

  • In Batch and Bash, commands communicate using plain text. If you want to extract a specific piece of information, you typically need to parse the text output using tools like findstr, grep, or awk.
  • In PowerShell, commands communicate using structured .NET objects. Each object carries properties and methods, so you can directly reference the data you need without text parsing.
Consolepowershell
Get-Process | Where-Object { $_.CPU -gt 5 } | Select-Object Name, CPU

where:

  • Get-Process returns a collection of process objects, not plain text.
  • Where-Object filters the objects using the CPU property directly.
  • Select-Object picks specific properties (Name, CPU) to display.
  • $_ refers to the current object in the pipeline.
Outputplaintext
Name                  CPU
----                  ---
ctfmon              6.375
explorer        68.421875
notepad          8.203125
powershell       5.984375
RuntimeBroker   13.171875
SearchApp          17.875
sihost           9.203125
WindowsTerminal   19.9375

Use Cases

PowerShell is used across a wide range of IT and development scenarios, including:

  • System administration: managing users, services, processes, and scheduled tasks on Windows machines.
  • Automation: replacing manual, repetitive tasks with reusable scripts (file processing, report generation, backups).
  • DevOps: integrating with CI/CD pipelines, provisioning infrastructure, and managing configuration (e.g., with Desired State Configuration).
  • Cloud management: administering Azure, AWS, and Microsoft 365 resources via dedicated PowerShell modules (Az, AWS.Tools, ExchangeOnlineManagement).
  • Cross-platform scripting: since PowerShell 7 runs on Linux and macOS, it's increasingly used in mixed-OS environments alongside Bash.
Navigation