Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PowerShell Installation

PowerShell Installation

Since version 6.0, PowerShell has been fully open source and cross-platform (PowerShell Core / PowerShell 7+), and can run on Windows, Linux, and macOS.


I. Installing PowerShell 7+ on Windows

Method 1: Use the MSI installer package (recommended)

  1. Open the official PowerShell GitHub releases page:
    👉 https://github.com/PowerShell/PowerShell/releases
  2. Find the latest version and download the Windows build: .msi Install packages
  3. Double-click to install, using the default path
  4. After installation, search for "PowerShell 7" and open it (it does not overwrite Windows PowerShell)

Method 2: Use the command line (Winget)

For Windows 10/11 with the Windows Package Manager installed:

winget install --id Microsoft.Powershell --source winget

Optional parameters:--silent means a silent install,--version 7.4.1 can specify a version


II. Installing PowerShell on Linux

Ubuntu / Debian



# Install dependencies

sudo apt update

sudo apt install -y wget apt-transport-https software-properties-common



# Import Microsoft GPG key

wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb



# Install PowerShell

sudo apt update

sudo apt install -y powershell

Launch PowerShell:

pwsh


CentOS / RHEL / Fedora

# 添加 Microsoft YUM 源

sudo dnf install -y https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm



# Install PowerShell

sudo dnf install -y powershell

Or for CentOS 7 use yum:

sudo yum install -y powershell


Arch Linux / Manjaro

sudo pacman -S powershell

If not found, you can use the AUR package manager (such as yay)


III. Installing PowerShell on macOS

Method 1: Use Homebrew (recommended)

brew install --cask powershell

Launch PowerShell:

pwsh

Method 2: Manually download the PKG installer

  1. Go to the GitHub releases page
    👉 https://github.com/PowerShell/PowerShell/releases
  2. Download .pkg the installer file (such as powershell-7.4.1-osx-x64.pkg)
  3. double-click to install and follow the prompts

IV. Installation Verification and Uninstallation

Verify whether the installation succeeded

pwsh --version

Uninstall PowerShell

Platform Uninstall method
Windows Control Panel -> Programs and Features -> Uninstall PowerShell 7
Ubuntu sudo apt remove powershell
CentOS sudo yum remove powershell
macOS (brew) brew uninstall powershell

Startup commands on different platforms

Platform Command
Windows pwsh.exe Or search for 'PowerShell 7' in the Start menu
Linux pwsh
macOS pwsh