PowerShell Genie

Installing PowerShell

Windows PowerShell 5.1 is already on any supported Windows machine, so there is nothing to install if 5.1 is all you need. PowerShell 7 is a separate download.

Lesson 3 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

In plain English

On Windows the least troublesome route is winget install Microsoft.PowerShell, which puts Windows PowerShell on your PATH. Note: since PowerShell 7.6, WinGet installs the MSIX package by default — add --installer-type wix if you want the MSI instead (the MSI is the better pick when you need elevation or scheduled tasks, which the packaged MSIX install cannot do) — the list of folders Windows searches whenever you type a command name. Being "on the PATH" is what lets you type Windows PowerShell from any folder instead of the full C:\Program Files\PowerShell\7\pwsh.exe. The MSI from the GitHub releases page does the same thing if winget is unavailable. On Linux, use your distribution's package manager after adding the Microsoft repository. On macOS, brew install powershell/tap/powershell.

One thing worth setting up on day one: install a terminal that supports the newer console features. Windows Terminal handles colour, tabs and Unicode correctly, where the old conhost window does not. PSReadLine, which gives you syntax colouring and history search at the prompt, ships with PowerShell 7 and is worth updating in 5.1.

See the objects move

Inspect this authored example with fictional data in the bounded browser model. The numbered stages show how its objects change.

Get-Command pwsh, powershell -ErrorAction SilentlyContinue
  1. Stage 1Get-Command-ErrorAction

    What happens

    Get-Command asks PowerShell to look up commands by name. Passing both pwsh and powershell asks whether each executable is on your path, and -ErrorAction SilentlyContinue stops it complaining about whichever one is missing. What comes back tells you which editions are installed and where their executables live.

    Worth remembering

    • 5.1 is preinstalled on Windows. 7 is a separate install.
    • winget install Microsoft.PowerShell is the simplest route on Windows.
    • Install Windows Terminal at the same time.
    • Installing 7 does not remove or upgrade 5.1.

    Check your understanding

    There is no runnable lab on this page — these run in your own terminal, so predict the answer first, then verify.

    Q1. You finish the Windows installer, open a brand-new terminal, type Windows PowerShell and press Enter. What do you expect to see?

    Answer: A PowerShell 7 prompt (PS C:\> style). If you see "'pwsh' is not recognized", the terminal was opened before the install finished — close it and open a fresh one so the updated PATH loads.

    Q2. Will installing PowerShell 7 remove or break your existing Windows PowerShell 5.1?

    Answer: No. The two install side by side: 5.1 stays exactly where it is, and 7 gets its own folder and its own Windows PowerShell command.

    Q3. After installing, Get-Command pwsh, powershell finds pwsh.exe but not powershell.exe. What is the most likely explanation?

    Answer: You are on macOS or Linux — powershell.exe (Windows PowerShell 5.1) is Windows-only and simply does not exist there.

    Primary documentation

    Install PowerShell on Windows

    Try it

    Illustrative output · values vary by environment

    1PS> Get-Command pwsh, powershell -ErrorAction SilentlyContinue

    Example reader

    Inspect this page's example

    Fictional browser data when supported

    Run supported commands against the practice data, or inspect the example without executing it.

    Ready to inspect.

      Shows which PowerShell executables are on your path and where they are.

      Show reference output
      CommandType  Name            Version       Source
      -----------  ----            -------       ------
      Application  pwsh.exe        7.5.2.0       C:\Program Files\PowerShell\7\pwsh.exe
      Application  powershell.exe  10.0.22621.0  C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

      Asks WinGet what it knows about the PowerShell package — a second way to confirm the install registered.

      Show reference output

      Illustrative output · values vary by environment

      CommandType  Name            Version    Source
      -----------  ----            -------    ------
      Application  pwsh.exe        7.5.2      C:\Program Files\PowerShell\7\pwsh.exe
      Application  powershell.exe  5.1.22621  C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

      Practise this

      Install and launch PowerShell

      Complete download, publisher verification, installation with PATH integration, and launch in the fictional Windows desktop. Your computer is unchanged.

      Review the lesson

      Keep going

      Next: Check your PowerShell version and edition
      Genie guideInstalling PowerShell

      Windows PowerShell 5.1 is already on any supported Windows machine, so there is nothing to install if 5.1 is all you need. PowerShell 7 is a separate download.