Lesson 1 of 5  ยท  Beginner

Introduction to PowerShell

โฑ ~10 minutes Beginner

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.

๐Ÿ’ก
Why learn PowerShell? With PowerShell you can automate repetitive tasks, manage Windows settings, work with files and folders, interact with APIs, and administer servers โ€” all with a few lines of code.

How to Open PowerShell

There are several ways to open PowerShell on Windows:

  • Press Win + X โ†’ choose Windows PowerShell or Terminal
  • Press Win + R, type powershell, press Enter
  • Search "PowerShell" in the Start menu
  • Right-click in any folder โ†’ Open in Terminal
โœ…
Recommendation: Use Windows Terminal with PowerShell as the profile. It has tabs, better colors, and modern features. Install it free from the Microsoft Store.

The PowerShell Prompt

When PowerShell opens, you'll see a prompt that looks like this:

Windows PowerShell
PS C:\Users\YourName> _

The prompt tells you:

  • PS โ€” you're in PowerShell
  • C:\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:

PowerShell โ€” Your First Commands
PS C:\> Get-Date
Wednesday, January 15, 2025 14:30:22

PS C:\> Write-Host "Hello, PowerShell!"
Hello, PowerShell!

PS C:\> Get-Location
Path
----
C:\

Navigating the File System

PowerShell uses familiar-looking commands (many with short aliases from Unix/DOS) to navigate:

Navigation
# See where you are
PS C:\> Get-Location

# List files and folders (like 'ls' or 'dir')
PS C:\> Get-ChildItem

# Change directory (like 'cd')
PS C:\> Set-Location C:\Users

# Go up one level
PS C:\Users> Set-Location ..

# Quick shortcut: cd works too!
PS C:\> cd C:\Windows
โ„น๏ธ
Aliases: PowerShell has many shortcuts. 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
โœ…
Pro tip: Press Ctrl+Space in some terminals to see all possible completions at once instead of cycling through them one by one.

Command History

Use the Up/Down arrow keys to scroll through previous commands. Press Ctrl+R to search your command history.

View Command History
# See your recent commands
PS C:\> Get-History

# Clear the screen (like 'cls')
PS C:\> Clear-Host

Getting Information About the System

Useful Info Commands
# PowerShell version
PS C:\> $PSVersionTable

# Current user
PS C:\> $env:USERNAME

# Computer name
PS C:\> $env:COMPUTERNAME

# OS info
PS C:\> Get-ComputerInfo | Select-Object WindowsProductName, OsVersion

๐Ÿงช Try It Yourself

  1. Open PowerShell on your computer
  2. Run Get-Date โ€” notice it returns a proper object, not just text
  3. Run Get-ChildItem C:\Windows โ€” explore the output
  4. Run $PSVersionTable โ€” find out which version of PowerShell you have
  5. 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