Maintaining PowerShell¶
Summary¶
Instructions for installing and updating PowerShell, help files and modules.
Notes:
- These tasks can take a few minutes, especially on older machines.
- Windows PowerShell 5.1 is still required for some legacy scripts, modules and Windows administration tasks.
- Most modern scripts, commands and modules are now written for PowerShell 7.
- PowerShell 7 installs side-by-side with Windows PowerShell 5.1.
- Windows PowerShell 5.1 uses
powershell.exe. - PowerShell 7 uses
pwsh.exe.
Requirements¶
Check that winget is available:
Search for available PowerShell packages:
Installing PowerShell¶
Windows PowerShell 5.1¶
Windows PowerShell 5.1 is the legacy built-in Windows version of PowerShell. It is installed by default on Windows 10, Windows 11, Windows Server 2016 and newer.
Check the installed Windows PowerShell version:
Launch Windows PowerShell 5.1:
Install or repair Windows PowerShell 5.1¶
On modern supported Windows versions, PowerShell 5.1 is part of Windows and is not normally installed using winget.
For older supported systems, Windows PowerShell 5.1 is installed through Windows Management Framework 5.1, not the normal PowerShell 7 winget package.
Important:
winget install Microsoft.PowerShell installs PowerShell 7, not Windows PowerShell 5.1.
PowerShell 7¶
PowerShell 7 is the modern, cross-platform version of PowerShell. It runs side-by-side with Windows PowerShell 5.1 and is the recommended version for most modern automation tasks.
Install PowerShell 7 using winget:
Install PowerShell 7 Preview:
Launch PowerShell 7:
Check the installed PowerShell 7 version:
Updating PowerShell¶
Update PowerShell 7 using winget¶
Update PowerShell 7:
Update PowerShell 7 Preview:
Update all available winget packages:
Check installed PowerShell packages:
Update-Module¶
Update all installed PowerShell modules:
Update all installed PowerShell modules without prompting for confirmation:
Update a specific PowerShell module:
Full syntax for Update-Module:
Update-Module
[[-Name] <String[]>]
[-RequiredVersion <String>]
[-MaximumVersion <String>]
[-Credential <PSCredential>]
[-Scope <String>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Force]
[-AllowPrerelease]
[-AcceptLicense]
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Update-Help¶
Update PowerShell help files:
Update PowerShell help files without prompting for confirmation:
Update help files for a specific module:
Full syntax for Update-Help:
Update-Help
[[-Module] <String[]>]
[-FullyQualifiedModule <ModuleSpecification[]>]
[[-SourcePath] <String[]>]
[-Recurse]
[[-UICulture] <CultureInfo[]>]
[-Credential <PSCredential>]
[-UseDefaultCredentials]
[-Force]
[-Scope <UpdateHelpScope>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Useful Version Checks¶
Check the current PowerShell version:
Check PowerShell executable paths:
Check installed modules:
Check available modules:
External Links¶
Microsoft PowerShell 7 installation article
Microsoft Windows PowerShell 5.1 article
Microsoft Windows Management Framework article