Installing PowerShell
Summary: in this tutorial, you will learn install powershell 7 on windows, macos, and linux. configure your terminal, set up vs code integration, install useful modules, and customize your powershell environment.
Installing PowerShell
While Windows ships with Windows PowerShell 5.1, modern work should use PowerShell 7+. This guide covers installing and configuring it on every major platform.
Why Install PowerShell 7?
Windows PowerShell 5.1 is stable but frozen — Microsoft only provides security updates, no new features. PowerShell 7+ is the actively developed, cross-platform version with:
- Cross-platform: Same code runs on Windows, macOS, and Linux
- Performance: Faster startup, lower memory usage, improved pipeline performance
- New features: Ternary operators, null-coalescing operators,
ForEach-Object -Parallel, and more - Better compatibility: Runs side-by-side with Windows PowerShell, doesn't break existing scripts
- Active development: Monthly releases with improvements and bug fixes
Installing PowerShell 7 doesn't replace Windows PowerShell — both coexist peacefully. Use pwsh for new work and powershell when you need legacy compatibility.
Windows
Windows PowerShell 5.1 (Already Installed)
Windows 10 and 11 include Windows PowerShell 5.1. Find it by searching for "PowerShell" in the Start menu. But for new work, install PowerShell 7.
Installing PowerShell 7 on Windows
Method 1: winget (Recommended)
winget install Microsoft.PowerShell
Method 2: MSI Installer
- Go to the PowerShell GitHub releases
- Download the
.msifile for your architecture (x64 for most systems) - Run the installer with default options
- Check "Add to PATH" and "Register Windows Event Logging"
Method 3: Microsoft Store
Search for "PowerShell" in the Microsoft Store and install it.
Verify the installation:
# Launch PowerShell 7
pwsh
# Check version
$PSVersionTable.PSVersion
After installing, you'll have both powershell.exe (5.1) and pwsh.exe (7+) on your system. They are completely independent and can run side by side.
macOS
Method 1: Homebrew (Recommended)
brew install powershell/tap/powershell
Method 2: Direct Download
Download the .pkg file from the GitHub releases page and run the installer.
Launch and verify:
pwsh
$PSVersionTable.PSVersion
Linux
Ubuntu / Debian
# Update packages and install prerequisites
sudo apt-get update
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository keys
source /etc/os-release
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
# Install PowerShell
sudo apt-get update
sudo apt-get install -y powershell
Fedora / RHEL / CentOS
# Register the Microsoft repository
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo dnf install -y powershell
Arch Linux
# From AUR
yay -S powershell-bin
Snap (Universal)
sudo snap install powershell --classic
Verify on any Linux:
pwsh
$PSVersionTable.PSVersion
Setting Up Your Terminal
Your terminal is where you'll spend most of your PowerShell time. The right terminal improves productivity through better rendering, keyboard shortcuts, and customization.
Windows Terminal (Recommended for Windows)
Windows Terminal is the best way to use PowerShell on Windows. It replaces the old console host with a modern application featuring:
- Tabs and panes: Multiple sessions in one window, split horizontally/vertically
- GPU acceleration: Smooth scrolling and rendering
- Unicode and emoji support: Full UTF-8, including complex scripts and symbols
- Customizable themes: Colors, fonts, backgrounds, transparency
- Profiles: Configure separate settings for PowerShell, CMD, WSL, SSH
- Keyboard shortcuts: Navigate, copy, paste, search without the mouse
# Install via winget
winget install Microsoft.WindowsTerminal
Configure PowerShell 7 as default:
- Open Windows Terminal
- Click the dropdown arrow next to the tabs → Settings
- Under "Default profile", select "PowerShell" (the one with the black icon, not the blue one)
- Save
Useful settings (Settings → PowerShell profile → Appearance):
- Color scheme: One Half Dark, Tango Dark, or Campbell
- Font: Cascadia Code (installed with Windows Terminal) — includes ligatures and Nerd Font icons
- Font size: 11-14
- Opacity/Acrylic: 85-95% for a nice translucent effect
VS Code Integration
VS Code is the ideal editor for PowerShell development. While you can write scripts in any text editor, VS Code with the PowerShell extension provides an integrated development environment that catches errors before you run code, offers intelligent auto-complete, and enables step-through debugging.
Why VS Code for PowerShell?
- IntelliSense: Auto-complete cmdlets, parameters, variables as you type
- Real-time analysis: PSScriptAnalyzer highlights issues before you save
- Integrated debugging: Set breakpoints, inspect variables, step through code
- Integrated terminal: Run and test code without switching windows
- Git integration: Version control built-in
- Free and open-source: No licensing costs, active community
# Install VS Code (if not already installed)
winget install Microsoft.VisualStudioCode
Install the PowerShell extension:
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X) - Search for "PowerShell"
- Install the one by Microsoft (extension ID:
ms-vscode.powershell)
This gives you:
- Syntax highlighting
- IntelliSense (auto-complete)
- Integrated debugging
- Script analysis (PSScriptAnalyzer)
- Code formatting
- Integrated terminal with PowerShell
Configure VS Code to use PowerShell 7:
Open Settings (Ctrl+,) and search for "terminal default profile". Set it to "PowerShell" (the 7+ version).
Or add to settings.json:
{
"terminal.integrated.defaultProfile.windows": "PowerShell",
"powershell.powerShellDefaultVersion": "PowerShell (x64)"
}
Configuring Your Profile
Your PowerShell profile runs every time you start a new session:
# See your profile path
$PROFILE
# Create it if it doesn't exist
if (!(Test-Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
# Edit in VS Code
code $PROFILE
Recommended Profile Setup
# ============================================
# PowerShell Profile
# ============================================
# --- Module Imports ---
# Import-Module Terminal-Icons # Uncomment after installing
# Import-Module posh-git # Uncomment after installing
# --- PSReadLine Configuration ---
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
# --- Aliases ---
Set-Alias -Name g -Value git
Set-Alias -Name which -Value Get-Command
Set-Alias -Name touch -Value New-Item
# --- Custom Functions ---
# Quick directory navigation
function .. { Set-Location .. }
function ... { Set-Location ../.. }
function home { Set-Location ~ }
# Create a directory and cd into it
function mkcd {
param([string]$Path)
New-Item -ItemType Directory -Path $Path -Force | Out-Null
Set-Location $Path
}
# Quick file search
function ff {
param([string]$Name)
Get-ChildItem -Recurse -Filter "*$Name*" -ErrorAction SilentlyContinue
}
# System info
function sysinfo {
[PSCustomObject]@{
Computer = $env:COMPUTERNAME
User = $env:USERNAME
OS = (Get-CimInstance Win32_OperatingSystem).Caption
PowerShell = $PSVersionTable.PSVersion.ToString()
Uptime = (Get-Uptime).ToString("dd\.hh\:mm\:ss")
}
}
# --- Custom Prompt ---
function prompt {
$path = $executionContext.SessionState.Path.CurrentLocation.Path
$path = $path.Replace($HOME, '~')
$gitBranch = ''
if (Test-Path .git) {
$gitBranch = " ($((git branch --show-current 2>$null) ?? ''))"
}
Write-Host "PS " -NoNewline -ForegroundColor Cyan
Write-Host $path -NoNewline -ForegroundColor Yellow
Write-Host $gitBranch -NoNewline -ForegroundColor Green
return "> "
}
Write-Host "PowerShell $($PSVersionTable.PSVersion) ready!" -ForegroundColor Green
Installing Useful Modules
PowerShell has a package manager called PowerShellGet that installs modules from the PowerShell Gallery:
# Search for modules
Find-Module -Name *posh*
# Install a module for the current user
Install-Module -Name ModuleName -Scope CurrentUser
# Update modules
Update-Module -Name ModuleName
Essential Modules
# Terminal-Icons: File and folder icons in directory listings
Install-Module -Name Terminal-Icons -Scope CurrentUser -Force
# posh-git: Git status in your prompt
Install-Module -Name posh-git -Scope CurrentUser -Force
# PSScriptAnalyzer: Lint and analyze your scripts
Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force
# z: Quick directory jumping (like autojump/zoxide)
Install-Module -Name z -Scope CurrentUser -Force
To use Terminal-Icons, add to your profile:
Import-Module Terminal-Icons
Now Get-ChildItem (or ls) shows beautiful file type icons!
Oh-My-Posh (Beautiful Prompts)
Oh-My-Posh gives you fancy, customizable prompts with Git status, battery, time, and more:
# Install Oh-My-Posh
winget install JanDeDobbeleer.OhMyPosh
# Install a Nerd Font (required for icons)
oh-my-posh font install CascadiaCode
Add to your profile:
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/catppuccin.omp.json" | Invoke-Expression
Browse themes:
Get-PoshThemes
Updating PowerShell
# Check current version
$PSVersionTable.PSVersion
# Update via winget (Windows)
winget upgrade Microsoft.PowerShell
# Update via Homebrew (macOS)
# brew upgrade powershell
# Update via apt (Ubuntu)
# sudo apt update && sudo apt upgrade powershell
Getting Help
PowerShell's help system is incredibly detailed, but needs to be downloaded first:
# Download/update help files (run as admin once)
Update-Help -Force -ErrorAction SilentlyContinue
# Now use help
Get-Help Get-Process
Get-Help Get-Process -Full
Get-Help Get-Process -Examples
Get-Help Get-Process -Online # Opens browser to Microsoft docs
Complete these tasks:
- Install PowerShell 7 (if not already installed)
- Verify the version with
$PSVersionTable - Create your profile file
- Add at least one custom alias and one custom function
- Set up PSReadLine with history-based prediction
Show Solution
# 1. Install (Windows)
winget install Microsoft.PowerShell
# 2. Launch PowerShell 7 and check version
pwsh
$PSVersionTable
# Should show PSVersion 7.x and PSEdition "Core"
# 3. Create profile
if (!(Test-Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
# 4. Add to profile (open with code $PROFILE)
Set-Alias -Name g -Value git
function weather {
param([string]$City = "London")
(Invoke-WebRequest "https://wttr.in/$City?format=3" -UseBasicParsing).Content
}
# 5. PSReadLine config (add to profile)
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
# Reload profile
. $PROFILE
- Use
Find-Moduleto search for modules related to "JSON" - Install
Terminal-Iconsand verify it works withGet-ChildItem - List all currently imported modules with
Get-Module
Show Solution
# 1. Search for JSON modules
Find-Module -Name *json* | Select-Object Name, Description -First 10
# 2. Install Terminal-Icons
Install-Module -Name Terminal-Icons -Scope CurrentUser -Force
Import-Module Terminal-Icons
Get-ChildItem ~ # Now shows icons next to files and folders
# 3. List imported modules
Get-Module | Select-Object Name, Version, ModuleType
# You'll see modules like:
# Microsoft.PowerShell.Management
# Microsoft.PowerShell.Utility
# PSReadLine
# Terminal-Icons (if imported)
Written by the ShellRAG Team
The ShellRAG editorial team writes practical, beginner-friendly PowerShell tutorials with tested code examples and real-world use cases. Every article is technically reviewed for accuracy and updated regularly.
Learn more about us →