How to Install PowerShell: Step-by-Step Guide
To install
PowerShell, download the latest installer from the official Microsoft GitHub page for your operating system, then run the installer and follow the prompts. On Windows, you can also install it via winget or chocolatey package managers for easy setup.Syntax
Installing PowerShell depends on your operating system and method. Here are common commands and steps:
- Windows: Use
winget install --id Microsoft.PowerShellor download the MSI installer. - macOS: Use
brew install --cask powershellor download the PKG installer. - Linux: Use your package manager like
apt,yum, or download the tar.gz package.
Each method installs PowerShell and makes it available as pwsh command.
powershell
winget install --id Microsoft.PowerShell
Example
This example shows how to install PowerShell on Windows using winget. It downloads and installs the latest stable version automatically.
powershell
winget install --id Microsoft.PowerShell -e --source winget
Output
Found PowerShell [Microsoft.PowerShell]
Installing PowerShell...
Successfully installed PowerShell.
Common Pitfalls
Common mistakes when installing PowerShell include:
- Not running the installer or package manager with administrator rights.
- Using outdated installers from unofficial sources.
- Confusing Windows PowerShell (built-in) with PowerShell Core (pwsh).
- Not adding PowerShell to the system PATH, causing
pwshcommand to fail.
Always use official Microsoft sources and run commands as admin.
powershell
# Wrong: Running winget without admin winget install --id Microsoft.PowerShell # Right: Run PowerShell as admin first Start-Process powershell -Verb runAs winget install --id Microsoft.PowerShell
Quick Reference
| Platform | Installation Method | Command or Link |
|---|---|---|
| Windows | winget package manager | winget install --id Microsoft.PowerShell |
| Windows | Chocolatey package manager | choco install powershell-core |
| Windows | MSI Installer | https://github.com/PowerShell/PowerShell/releases |
| macOS | Homebrew | brew install --cask powershell |
| macOS | PKG Installer | https://github.com/PowerShell/PowerShell/releases |
| Linux | APT (Debian/Ubuntu) | sudo apt install -y powershell |
| Linux | YUM (CentOS/RHEL) | sudo yum install -y powershell |
| Linux | Tarball | https://github.com/PowerShell/PowerShell/releases |
Key Takeaways
Use official Microsoft sources or trusted package managers to install PowerShell.
Run installation commands with administrator or root privileges to avoid permission errors.
PowerShell Core is installed as the 'pwsh' command, different from Windows PowerShell.
Check your system PATH if 'pwsh' command is not recognized after installation.
Use platform-specific package managers for the easiest and most reliable installation.