PowerShell Installation Guide

This guide provides comprehensive instructions for installing PowerShell on various operating systems. PowerShell is a powerful task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language.

Prerequisites

Before you begin, ensure your system meets the following requirements:

Installing PowerShell on Windows

Windows 10 and Windows Server 2019+

PowerShell 7 (the latest, cross-platform version) is available as a direct download from Microsoft. It's also included as the default by-default Windows PowerShell in newer versions of Windows.

Option 1: Using the Microsoft Store

The easiest way to install PowerShell 7 is through the Microsoft Store:

  1. Open the Microsoft Store app.
  2. Search for "PowerShell".
  3. Select the latest version of PowerShell and click "Get" or "Install".

Option 2: Using MSI Package

You can download the MSI installer directly from the PowerShell releases page on GitHub.

  1. Navigate to the GitHub releases page.
  2. Download the appropriate MSI installer for your Windows architecture (x64 or x86).
  3. Run the downloaded MSI file and follow the on-screen instructions.

Older Windows Versions (Windows 7, 8, Server 2012 R2)

For older Windows versions, you will likely install Windows PowerShell 5.1, which is included by default in many Windows releases. You can also install PowerShell Core 6.x or 7.x manually.

To install Windows PowerShell 5.1 (if not already present):

  1. Open PowerShell as an administrator.
  2. Run the command: Install-WindowsFeature -Name PowerShell
  3. Follow any prompts.
Note: Windows PowerShell 5.1 is built on the .NET Framework, while PowerShell 7 is built on .NET Core/.NET 5+ and is cross-platform.

Installing PowerShell on macOS

PowerShell 7 is the recommended version for macOS.

Option 1: Using Homebrew (Recommended)

If you have Homebrew installed, use the following commands:

brew install --cask powershell

Option 2: Using DMG Package

  1. Download the latest stable DMG package from the PowerShell releases page on GitHub.
  2. Double-click the DMG file to open it.
  3. Double-click the package installer and follow the on-screen instructions.

After installation, you can launch PowerShell by typing pwsh in your Terminal.

Installing PowerShell on Linux

PowerShell 7 is available for various Linux distributions.

Debian/Ubuntu

Using apt repository:

# Update the list of packages
sudo apt-get update

# Install prerequisites
sudo apt-get install -y curl wget apt-transport-https software-properties-common

# Register the Microsoft package repository
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/microsoft.gpg

echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/$(lsb_release -rs)/prod $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/microsoft.list

# Update package list and install PowerShell
sudo apt-get update
sudo apt-get install -y powershell

Fedora/CentOS/RHEL

Using yum/dnf repository:

# Register the Microsoft package repository
sudo rpm -E https://packages.microsoft.com/release/2/prod.noarch.rpm | sudo tee /etc/yum.repos.d/microsoft.repo

# Update package list and install PowerShell
sudo yum update -y
sudo yum install -y powershell
Tip: After installation on Linux, you can launch PowerShell by typing pwsh in your terminal.

Verifying Installation

To verify your installation, open your terminal or command prompt and run:

pwsh -version

This command should output the installed version of PowerShell.

Important: Always refer to the official PowerShell documentation for the most up-to-date installation instructions and system requirements.