PowerShell Installation and Setup
PowerShell 5.1 comes pre-installed on Windows 10 and Windows 11. However, PowerShell 7 (the latest cross-platform version) needs a separate installation. This topic covers how to install PowerShell 7 on Windows, Linux, and macOS, and how to set up the environment for daily use.
Check If PowerShell Is Already Installed
Before installing, check the existing PowerShell version on the system.
On Windows:
- Press Win + R, type
powershell, and press Enter - In the console, run:
$PSVersionTable.PSVersion
Output:
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 4291
If the major version is 5, that is Windows PowerShell 5.1. To get PowerShell 7, follow the installation steps below.
Installing PowerShell 7 on Windows
Method 1 – Using the MSI Installer (Recommended for Beginners)
- Go to the official GitHub releases page: https://github.com/PowerShell/PowerShell/releases
- Download the latest
.msifile for Windows (example:PowerShell-7.4.0-win-x64.msi) - Double-click the downloaded file
- Follow the setup wizard — click Next → Accept the license → Choose installation folder → Finish
- Open the Start menu, search for PowerShell 7, and launch it
Method 2 – Using winget (Windows Package Manager)
Open Command Prompt or the existing PowerShell and run:
winget install --id Microsoft.PowerShell --source winget
This command downloads and installs PowerShell 7 automatically.
Method 3 – Using the PowerShell Command
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
This runs Microsoft's official installation script directly from the web.
Installing PowerShell 7 on Linux (Ubuntu/Debian)
Open the terminal and run these commands one by one:
# Step 1: Update packages
sudo apt-get update
# Step 2: Install prerequisite packages
sudo apt-get install -y wget apt-transport-https software-properties-common
# Step 3: Download and register the Microsoft repository key
wget -q "https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb"
sudo dpkg -i packages-microsoft-prod.deb
# Step 4: Update package list again
sudo apt-get update
# Step 5: Install PowerShell
sudo apt-get install -y powershell
Start PowerShell on Linux:
pwsh
Installing PowerShell 7 on macOS
Use Homebrew (the macOS package manager):
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install PowerShell using Homebrew
brew install --cask powershell
Start PowerShell on macOS:
pwsh
Verify the Installation
After installation, open PowerShell 7 and run:
$PSVersionTable
Expected output on PowerShell 7:
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 7.4.0}
Setting Up Visual Studio Code for PowerShell
Visual Studio Code (VS Code) is the recommended editor for writing PowerShell scripts. It provides syntax highlighting, auto-completion, and an integrated terminal.
Steps to Set Up VS Code with PowerShell
- Download and install VS Code from https://code.visualstudio.com
- Open VS Code
- Press Ctrl + Shift + X to open the Extensions panel
- Search for PowerShell in the Extensions search bar
- Click Install on the extension by Microsoft
- After installation, open or create a file with the
.ps1extension - VS Code will automatically use the PowerShell extension
PowerShell Execution Policy
By default, Windows blocks running PowerShell scripts as a security measure. The Execution Policy controls this behavior.
| Policy Name | What It Does |
|---|---|
| Restricted | No scripts allowed — commands only (default on Windows) |
| AllSigned | Only signed scripts from trusted publishers run |
| RemoteSigned | Local scripts run freely; downloaded scripts need a signature |
| Unrestricted | All scripts run — not recommended for production |
| Bypass | Nothing is blocked — used in automated pipelines |
Check the current policy:
Get-ExecutionPolicy
Set the policy to RemoteSigned (safe for development):
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
PowerShell Profile File
A PowerShell profile is a script that runs automatically every time PowerShell starts. It works like a startup configuration file — similar to .bashrc on Linux.
Find the profile file path:
$PROFILE
Create the profile file if it does not exist:
New-Item -Path $PROFILE -ItemType File -Force
Open the profile in Notepad to edit it:
notepad $PROFILE
Example profile content – add a custom greeting:
Write-Host "Welcome to PowerShell 7!" -ForegroundColor Green
Write-Host "Today is: $(Get-Date -Format 'dddd, MMMM dd yyyy')"
Save and restart PowerShell — the greeting appears every time the shell opens.
Installation Summary
| Platform | Installation Method | Start Command |
|---|---|---|
| Windows | MSI installer or winget | Search "PowerShell 7" in Start menu |
| Linux (Ubuntu) | apt-get package manager | pwsh |
| macOS | Homebrew | pwsh |
With PowerShell 7 installed and VS Code configured, the environment is ready for writing, testing, and running PowerShell scripts and cmdlets.
