> For the complete documentation index, see [llms.txt](https://www.osdeploy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.osdeploy.com/core-components/powershell/install-powershell.md).

# Install PowerShell 7

{% embed url="<https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.6>" %}

OSDeploy requires **PowerShell 7.6 or later**. PowerShell 7 installs side-by-side with Windows PowerShell 5.1 and does not replace it. It is installed to `$env:ProgramFiles\PowerShell\7` and launched using `pwsh`.

These instructions target **Windows only** (amd64 and arm64). The snippets detect the current architecture automatically.

{% hint style="info" %}
PowerShell releases frequently. Always check the [PowerShell GitHub Releases](https://github.com/PowerShell/PowerShell/releases/latest) page for the current version and update the `$Version` variable accordingly.
{% endhint %}

## Why Not WinGet?

Beginning with PowerShell 7.6.0, WinGet installs the **MSIX package by default**. MSIX packages run inside an application sandbox that virtualizes filesystem and registry access. This sandbox **blocks system-level operations**, including commands that call `dism.exe`. This makes MSIX-based installations incompatible with OSD workflows such as OSDCloud.

{% hint style="warning" %}
Use the **MSI package** for all system and enterprise deployment scenarios.
{% endhint %}

## Download the MSI

The following snippet detects the system architecture, creates the download directory, and saves the installer to `$env:ProgramData\OSDeployCore\software\Microsoft.PowerShell`.

`curl.exe` is used for downloads — it is faster and more reliable than `Invoke-WebRequest` in Windows system contexts.

```powershell
# Update $Version to match the latest release:
# https://github.com/PowerShell/PowerShell/releases/latest
$Version        = '7.6.1'
$Arch           = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' }
$MsiFileName    = "PowerShell-$Version-win-$Arch.msi"
$MsiUrl         = "https://github.com/PowerShell/PowerShell/releases/download/v$Version/$MsiFileName"
$DownloadFolder = "$env:ProgramData\OSDeployCore\software\Microsoft.PowerShell"
$MsiPath        = Join-Path $DownloadFolder $MsiFileName

if (-not (Test-Path $DownloadFolder)) {
    New-Item -Path $DownloadFolder -ItemType Directory -Force | Out-Null
}

curl.exe -L -o $MsiPath $MsiUrl
```

## Install the MSI

The following snippet silently installs the MSI with all recommended options enabled. Source: [Install the MSI package with command-line options](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.6#install-the-msi-package-with-command-line-options).

```powershell
# Update $Version to match the version you downloaded
$Version  = '7.6.1'
$Arch     = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' }
$MsiPath  = "$env:ProgramData\OSDeployCore\software\Microsoft.PowerShell\PowerShell-$Version-win-$Arch.msi"

$msiParams = @(
    "/package `"$MsiPath`""
    '/quiet'
    'ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1'
    'ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1'
    'ENABLE_PSREMOTING=1'
    'REGISTER_MANIFEST=1'
    'USE_MU=1'
    'ENABLE_MU=1'
    'ADD_PATH=1'
)
msiexec.exe @msiParams
```

## After Installation

PowerShell 7 is installed to `$env:ProgramFiles\PowerShell\7`. Launch it from the Start Menu or by running `pwsh` in any terminal. The installer adds `pwsh` to the system `PATH` automatically when `ADD_PATH=1` is set.

To verify the installation:

```powershell
pwsh --version
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.osdeploy.com/core-components/powershell/install-powershell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
