Introduction to PowerShell
Discover Microsoft's powerful cross-platform shell and scripting language for system automation.
What You'll Learn
- What PowerShell is and how it differs from CMD and bash
- Windows PowerShell 5.1 vs PowerShell 7+ (Core)
- Execution policies and how to configure them
- Your first cmdlets: Get-Date, Get-Location, Write-Host
What Is PowerShell?
PowerShell is Microsoft's modern command-line shell and scripting language. Unlike the traditional Command Prompt (CMD) that outputs plain text, PowerShell works with .NET objects โ meaning every command returns structured data you can filter, sort, and manipulate.
๐ฅ๏ธ Real-World Analogy: CMD is like reading a newspaper โ you get raw text. PowerShell is like a spreadsheet โ you get columns, rows, types, and can instantly sort, filter, and calculate.
Why PowerShell Over CMD?
- Object pipeline โ Pipe structured data, not just text
- Powerful scripting โ Full programming language with functions, loops, error handling
- Cross-platform โ PowerShell 7+ runs on Windows, macOS, and Linux
- Active Directory & Azure โ The standard tool for Microsoft administration
- .NET integration โ Access the entire .NET framework from the shell
โ ๏ธ Common Confusion
Windows PowerShell (v5.1, ships with Windows) and PowerShell (v7+, cross-platform) are separate products. PowerShell 7+ is the actively developed version. You can run both side by side.
First PowerShell Commands
See PowerShell basics and how they compare to CMD.
// Introduction to PowerShell โ simulated in JavaScript
console.log("=== What is PowerShell? ===");
console.log();
console.log("PowerShell is a cross-platform task automation solution");
console.log("that combines a command-line shell, a scripting language,");
console.log("and a configuration management framework.");
console.log();
console.log("=== PowerShell vs CMD ===");
const comparison = [
{ feature: "Output Type", cmd: "Plain text", ps: "Objects (.NET)" },
{ feature: "Scripting", cmd
...Setting Up PowerShell
On Windows 10/11, PowerShell 5.1 is already installed. Just press Win+X and choose "Terminal" or search for "PowerShell". For the latest version (PowerShell 7+), download it from the official GitHub repository or use winget install Microsoft.PowerShell.
On macOS, install via Homebrew: brew install --cask powershell, then run pwsh. On Linux, use your package manager โ for Ubuntu: sudo apt install powershell.
Execution Policies
By default, Windows blocks PowerShell scripts for security. You need to set an execution policy before running .ps1 files. The recommended setting for development is RemoteSigned:
PS> Get-ExecutionPolicy Restricted PS> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser PS> Get-ExecutionPolicy RemoteSigned
Versions & Setup
Explore PowerShell editions and execution policies.
// PowerShell Versions & Setup โ simulated in JavaScript
console.log("=== PowerShell Editions ===");
console.log();
console.log("๐ Windows PowerShell (5.1)");
console.log(" Built into Windows 10/11. Uses .NET Framework.");
console.log(" Executable: powershell.exe");
console.log();
console.log("๐ PowerShell 7+ (Core)");
console.log(" Cross-platform, open-source. Uses .NET 6+.");
console.log(" Executable: pwsh.exe / pwsh");
console.log(" Install: https://github.com/PowerShell/PowerShel
...๐ก Pro Tip
Press Tab to autocomplete cmdlet names, parameters, and file paths. Press Ctrl+Space in PowerShell 7+ for IntelliSense-like suggestions. Use Get-Help cmdlet -Online to open the full documentation in your browser.
๐ Quick Reference
| Cmdlet | Alias | Description |
|---|---|---|
| Get-Date | โ | Current date/time |
| Get-Location | pwd | Current directory |
| Set-Location | cd | Change directory |
| Get-ChildItem | ls / dir | List files & folders |
| Write-Host | โ | Print to console |
| Get-Help | help | Show cmdlet documentation |
๐ Lesson Complete!
You now understand what PowerShell is, how it differs from CMD, and how to get set up. Next up: mastering the Verb-Noun cmdlet system and parameters.
Sign up for free to track which lessons you've completed and get learning reminders.