Introduction to PowerShell
What is PowerShell?
PowerShell is a powerful command-line shell and scripting language built by Microsoft. It's installed by default on all modern Windows systems and is also available on macOS and Linux.
Unlike the old cmd.exe (Command Prompt), PowerShell works with objects, not just plain text. This makes it incredibly powerful for automating tasks, managing systems, and processing data.
How to Open PowerShell
There are several ways to open PowerShell on Windows:
- Press
Win + Xโ choose Windows PowerShell or Terminal - Press
Win + R, typepowershell, press Enter - Search "PowerShell" in the Start menu
- Right-click in any folder โ Open in Terminal
The PowerShell Prompt
When PowerShell opens, you'll see a prompt that looks like this:
The prompt tells you:
PSโ you're in PowerShellC:\Users\YourNameโ your current directory (location)>โ ready to accept a command
Your First Commands
Let's run some commands. Type each one and press Enter:
Navigating the File System
PowerShell uses familiar-looking commands (many with short aliases from Unix/DOS) to navigate:
cd is an alias for Set-Location, ls and dir are aliases for Get-ChildItem. You'll learn more about aliases in Lesson 3.Tab Completion
One of PowerShell's best features: press Tab while typing to auto-complete commands, parameters, and file paths.
- Type
Get-Cโ press Tab โ cycles through all commands starting with Get-C - Type
Get-ChildItem C:\Winโ press Tab โ completes the path - Type
Get-ChildItem -โ press Tab โ cycles through parameters
Command History
Use the Up/Down arrow keys to scroll through previous commands. Press Ctrl+R to search your command history.
Getting Information About the System
๐งช Try It Yourself
- Open PowerShell on your computer
- Run
Get-Dateโ notice it returns a proper object, not just text - Run
Get-ChildItem C:\Windowsโ explore the output - Run
$PSVersionTableโ find out which version of PowerShell you have - Use Tab completion while typing a command
Key Takeaways
- PowerShell works with objects, not just text โ this makes it much more powerful
- The prompt shows your current location in the file system
- Navigation commands:
Get-Location,Set-Location,Get-ChildItem - Tab completion is your best friend โ use it constantly
- Use โ/โ arrows to recall previous commands