How to Install PowerShell 7

PowerShell 7 represents a significant leap forward in Microsoft’s cross-platform automation and configuration management framework. Built on .NET, it offers enhanced performance, new language features, and expanded compatibility across Windows, macOS, and Linux. This guide will walk you through the process of installing PowerShell 7, ensuring you can leverage its powerful capabilities on your preferred operating system. Whether you’re an IT professional managing servers, a developer building automation scripts, or an enthusiast exploring new technologies, understanding the installation process is the first step to unlocking its potential.

Understanding PowerShell 7: A Cross-Platform Evolution

Before diving into the installation, it’s beneficial to grasp what makes PowerShell 7 a compelling choice. Unlike its predecessors, which were primarily Windows-centric, PowerShell 7 is designed from the ground up for cross-platform use. This means you can write and execute scripts that function identically whether you’re on a Windows desktop, a Linux server, or a macOS workstation.

Key Advantages of PowerShell 7

PowerShell 7 brings a host of improvements and new features that streamline automation and management tasks. Some of the most notable advantages include:

  • Cross-Platform Compatibility: Run PowerShell scripts on Windows, macOS, and Linux. This is a game-changer for heterogeneous environments.
  • Performance Improvements: Built on .NET 6 (or later), PowerShell 7 offers significant performance gains over older versions, making scripts run faster and consume fewer resources.
  • New Language Features: Enjoy modern language constructs like ternary operators, null-coalescing assignment operators, and improved pipeline chain operators (&&, ||, ?:), enhancing script readability and conciseness.
  • Remoting Enhancements: Improved SSH-based remoting allows for more secure and flexible remote management across different operating systems.
  • Compatibility: It maintains backward compatibility with many PowerShell 5.1 modules, easing the transition for existing users.
  • Open Source: PowerShell 7 is an open-source project, fostering community involvement and transparency.

PowerShell 7 vs. Windows PowerShell 5.1

It’s important to distinguish between PowerShell 7 and the Windows PowerShell 5.1 that comes pre-installed on many Windows systems. Windows PowerShell 5.1 is built on the .NET Framework, while PowerShell 7 is built on .NET Core (now .NET). This fundamental difference enables PowerShell 7’s cross-platform capabilities and its modern feature set. While Windows PowerShell 5.1 will continue to be supported for the life of its supported Windows releases, PowerShell 7 is the future of PowerShell, offering continuous innovation and broader applicability. You can often have both versions installed side-by-side on Windows, allowing for gradual migration and testing.

Installing PowerShell 7 on Windows

Installing PowerShell 7 on Windows is straightforward, with several methods available to suit different needs and preferences. Whether you prefer a graphical installer or command-line management, you can have PowerShell 7 up and running in minutes.

Method 1: Using the MSI Installer (Recommended for Most Users)

The Microsoft Installer (.msi) package provides a user-friendly graphical installation experience.

  1. Download the Latest Release:

    • Navigate to the official PowerShell GitHub repository’s releases page: https://github.com/PowerShell/PowerShell/releases
    • Look for the latest stable release (e.g., v7.x.x).
    • Under the “Assets” section, download the appropriate MSI file for your Windows architecture (usually PowerShell-7.x.x-win-x64.msi for 64-bit systems).
  2. Run the Installer:

    • Locate the downloaded .msi file and double-click it to launch the installer.
    • The setup wizard will guide you through the process.
    • Accept the License Terms: Read and accept the license agreement.
    • Choose Installation Options:
      • Destination Folder: You can typically leave the default installation path, or choose a custom location.
      • Optional Features: The installer usually offers options like “Add PowerShell to PATH” (highly recommended for easy access from the command line) and “Register PowerShell 7 as the default version” (consider this if you want powershell.exe to launch PowerShell 7 instead of Windows PowerShell 5.1, though be cautious if you have scripts that depend on 5.1).
    • Click “Install”: The installer will copy the necessary files to your system.
    • User Account Control (UAC): You may be prompted to allow the application to make changes to your device; click “Yes.”
  3. Verify the Installation:

    • Open a new Command Prompt or PowerShell window.
    • Type pwsh and press Enter. This should launch PowerShell 7.
    • To confirm the version, run the command: $PSVersionTable.PSVersion. You should see the version number of PowerShell 7.

Method 2: Using Winget (Windows Package Manager)

Winget is a command-line package manager for Windows, making it easy to install applications directly from the terminal.

  1. Open PowerShell or Command Prompt as Administrator:

    • Search for “PowerShell” or “cmd” in the Start Menu, right-click, and select “Run as administrator.”
  2. Install PowerShell 7:

    • Execute the following command:
      bash
      winget install --id Microsoft.PowerShell --source winget
    • Winget will find the latest available version of PowerShell, download it, and install it. You may be prompted to agree to source agreements.
  3. Verify the Installation:

    • Close and reopen your terminal window.
    • Type pwsh and press Enter.
    • Run $PSVersionTable.PSVersion to confirm the version.

Method 3: Using Chocolatey (Third-Party Package Manager)

Chocolatey is another popular package manager for Windows. If you use Chocolatey, this is a convenient method.

  1. Open PowerShell or Command Prompt as Administrator:

    • Ensure Chocolatey is installed. If not, follow the instructions on the Chocolatey website to install it.
  2. Install PowerShell 7:

    • Execute the following command:
      bash
      choco install powershell
    • Follow any prompts from Chocolatey to confirm the installation.
  3. Verify the Installation:

    • Open a new terminal window.
    • Type pwsh and press Enter.
    • Run $PSVersionTable.PSVersion to confirm the version.

Installing PowerShell 7 on macOS

PowerShell 7 offers excellent support for macOS, allowing you to harness its scripting power on Apple’s operating system.

Method 1: Using Homebrew (Recommended for macOS Users)

Homebrew is the de facto package manager for macOS.

  1. Install Homebrew (if you haven’t already):

    • Open the Terminal application.
    • Paste the following command and press Enter:
      bash
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    • Follow the on-screen instructions to complete the Homebrew installation.
  2. Install PowerShell 7:

    • In the Terminal, run:
      bash
      brew install powershell
    • Homebrew will download and install the latest stable version of PowerShell 7.
  3. Verify the Installation:

    • Close and reopen your Terminal window.
    • Type pwsh and press Enter.
    • Run $PSVersionTable.PSVersion to confirm the version.

Method 2: Using a Binary Package

You can also download and install PowerShell 7 directly from the GitHub releases page for macOS.

  1. Download the macOS Package:

    • Go to the PowerShell GitHub releases page: https://github.com/PowerShell/PowerShell/releases
    • Download the .pkg file for macOS (e.g., PowerShell-7.x.x-osx-x64.pkg).
  2. Run the Installer:

    • Double-click the downloaded .pkg file.
    • Follow the prompts in the installer wizard. You’ll likely need to grant permissions and accept the license.
  3. Verify the Installation:

    • Open the Terminal application.
    • Type pwsh and press Enter.
    • Run $PSVersionTable.PSVersion to confirm the version.

Installing PowerShell 7 on Linux

PowerShell 7 is fully supported on various Linux distributions, making it a powerful tool for server administration and cross-platform scripting. The installation process varies slightly depending on your Linux distribution.

Installing on Debian-based Distributions (e.g., Ubuntu, Debian)

  1. Register the Microsoft Package Repository:

    • Open your terminal.
    • Install the apt-transport-https package if you don’t have it already:
      bash
      sudo apt update
      sudo apt install -y curl apt-transport-https gnupg2
    • Import the Microsoft GPG key:
      bash
      curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.list | sudo tee /etc/apt/sources.list.d/microsoft-prod.list

      (Note: Replace $(lsb_release -rs) with your specific Ubuntu version if the command doesn’t auto-detect correctly.)
  2. Install PowerShell 7:

    • Update your package list:
      bash
      sudo apt update
    • Install PowerShell:
      bash
      sudo apt install -y powershell
  3. Verify the Installation:

    • Run:
      bash
      pwsh
    • Check the version with: $PSVersionTable.PSVersion.

Installing on Red Hat-based Distributions (e.g., Fedora, CentOS, RHEL)

  1. Register the Microsoft Package Repository:

    • Open your terminal.
    • Install the dnf-plugins-core package (for Fedora 22+ and RHEL/CentOS 8+):
      bash
      sudo dnf install -y dnf-plugins-core
    • If you are on an older version (e.g., CentOS 7), use yum instead of dnf.
    • Import the Microsoft GPG key:
      bash
      sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    • Register the repository:
      • For Fedora:
        bash
        sudo dnf config-manager --add-repo https://packages.microsoft.com/config/fedora/$(rpm -E %fedora)/packages-microsoft-prod.repo
      • For RHEL/CentOS:
        bash
        sudo dnf config-manager --add-repo https://packages.microsoft.com/config/rhel/$(rpm -E %rhel)/packages-microsoft-prod.repo
  2. Install PowerShell 7:

    • Update your package list:
      bash
      sudo dnf update -y
    • Install PowerShell:
      bash
      sudo dnf install -y powershell
  3. Verify the Installation:

    • Run:
      bash
      pwsh
    • Check the version with: $PSVersionTable.PSVersion.

Installing on macOS (using Binary Tarball)

For Linux distributions not covered by the above package managers, or if you prefer manual installation, you can use binary tarballs.

  1. Download the Binary Tarball:

    • Visit the PowerShell GitHub releases page: https://github.com/PowerShell/PowerShell/releases
    • Download the appropriate .tar.gz file for your Linux architecture (e.g., PowerShell-7.x.x-linux-x64.tar.gz).
  2. Extract the Tarball:

    • Open your terminal.
    • Navigate to the directory where you downloaded the file.
    • Extract the archive to a desired location (e.g., /usr/local/bin or a user-specific directory):
      bash
      sudo tar zxvf PowerShell-7.x.x-linux-x64.tar.gz -C /usr/local/bin/

      (Replace 7.x.x with the actual version number and adjust the -C path as needed.)
  3. Create a Symbolic Link (Optional but Recommended):

    • To make pwsh easily executable from anywhere, create a symbolic link:
      bash
      sudo ln -s /usr/local/bin/pwsh /usr/local/bin/pwsh

      (Adjust the source path if you extracted to a different location.)
  4. Verify the Installation:

    • Close and reopen your terminal.
    • Type pwsh and press Enter.
    • Run $PSVersionTable.PSVersion to confirm the version.

Post-Installation and Getting Started

Once PowerShell 7 is installed, you’re ready to start exploring its capabilities. The pwsh command will launch the PowerShell 7 interactive shell. From here, you can begin running commands and scripts.

Launching PowerShell 7

  • Windows: Search for “PowerShell 7” in the Start Menu, or open Command Prompt/Windows PowerShell and type pwsh.
  • macOS/Linux: Open your terminal and type pwsh.

Basic Commands to Test

  • Check Version:
    powershell
    $PSVersionTable.PSVersion
  • Get System Information:
    powershell
    Get-ComputerInfo
  • List Running Processes:
    powershell
    Get-Process
  • Navigate Directories:
    powershell
    cd C:UsersYourUsername # Windows
    cd ~/Documents # macOS/Linux

Managing Multiple PowerShell Versions on Windows

If you have both Windows PowerShell 5.1 and PowerShell 7 installed on Windows, they can coexist.

  • Windows PowerShell 5.1 is launched by typing powershell.exe.
  • PowerShell 7 is launched by typing pwsh.exe (or simply pwsh).

You can configure which version is the default when you type powershell.exe or pwsh.exe during installation or by modifying your system’s PATH environment variable. For most new projects and automation, it’s recommended to use and develop with PowerShell 7.

Further Exploration

  • Modules: PowerShell relies heavily on modules for extending its functionality. You can discover and install modules using the PowerShell Gallery:
    powershell
    # Find modules
    Find-Module -Name SomeModuleName
    # Install a module
    Install-Module -Name SomeModuleName
  • Scripting: Begin writing your own scripts to automate tasks. PowerShell offers a rich set of cmdlets and a powerful scripting language.

By following these installation steps, you are now equipped to leverage the full power of PowerShell 7 across your computing environments, paving the way for more efficient and robust automation.

Leave a Comment

Your email address will not be published. Required fields are marked *

FlyingMachineArena.org is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. Amazon, the Amazon logo, AmazonSupply, and the AmazonSupply logo are trademarks of Amazon.com, Inc. or its affiliates. As an Amazon Associate we earn affiliate commissions from qualifying purchases.
Scroll to Top