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:

  1. Press Win + R, type powershell, and press Enter
  2. 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)

  1. Go to the official GitHub releases page: https://github.com/PowerShell/PowerShell/releases
  2. Download the latest .msi file for Windows (example: PowerShell-7.4.0-win-x64.msi)
  3. Double-click the downloaded file
  4. Follow the setup wizard — click Next → Accept the license → Choose installation folder → Finish
  5. 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

  1. Download and install VS Code from https://code.visualstudio.com
  2. Open VS Code
  3. Press Ctrl + Shift + X to open the Extensions panel
  4. Search for PowerShell in the Extensions search bar
  5. Click Install on the extension by Microsoft
  6. After installation, open or create a file with the .ps1 extension
  7. 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 NameWhat It Does
RestrictedNo scripts allowed — commands only (default on Windows)
AllSignedOnly signed scripts from trusted publishers run
RemoteSignedLocal scripts run freely; downloaded scripts need a signature
UnrestrictedAll scripts run — not recommended for production
BypassNothing 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

PlatformInstallation MethodStart Command
WindowsMSI installer or wingetSearch "PowerShell 7" in Start menu
Linux (Ubuntu)apt-get package managerpwsh
macOSHomebrewpwsh

With PowerShell 7 installed and VS Code configured, the environment is ready for writing, testing, and running PowerShell scripts and cmdlets.

Leave a Comment