HoRain云--2026最新PowerShell跨平台安装指南
HoRain 云小助手个人主页⛺️生活的理想就是为了理想的生活!⛳️ 推荐前些天发现了一个超棒的服务器购买网站性价比超高大内存超划算忍不住分享一下给大家。点击跳转到网站。目录⛳️ 推荐PowerShell 安装指南 (2026) 快速查看当前版本一、Windows 系统安装方法1通过 Microsoft Store最简单⭐方法2使用 MSI 安装包推荐方法3使用 wingetWindows 11推荐方法4使用 Chocolatey软件包管理器⚠️ 重要提示启用执行策略二、Linux 系统安装Ubuntu/DebianCentOS/RHEL/FedoraopenSUSE/SLESArch Linux三、macOS 系统安装方法1使用 Homebrew推荐⭐方法2下载PKG安装包方法3使用 MacPorts四、验证安装五、常见问题解决❗ 问题1: pwsh 命令找不到❗ 问题2: 执行策略限制❗ 问题3: .NET Framework 依赖缺失六、卸载 PowerShellWindowsmacOSLinux七、升级 PowerShellWindows (winget)macOS (Homebrew)Linux八、推荐的后续操作 安装方式对比表PowerShell 安装指南 (2026)PowerShell 是微软开发的任务自动化与配置管理框架现已实现跨平台支持Windows/Linux/macOS。以下是完整安装教程 快速查看当前版本# 检查是否已安装 pwsh --version # PowerShell 7 powershell.exe -version # Windows PowerShell 5.1一、Windows 系统安装方法1通过 Microsoft Store最简单⭐打开Microsoft Store搜索 PowerShell点击获取/安装完成后运行pwsh启动方法2使用 MSI 安装包推荐系统架构下载地址Windows x64https://github.com/PowerShell/PowerShell/releases/latest/download/PowerShell-7.x-win-x64.msiWindows ARM64https://github.com/PowerShell/PowerShell/releases/latest/download/PowerShell-7.x-win-arm64.msiWindows x86https://github.com/PowerShell/PowerShell/releases/latest/download/PowerShell-7.x-win-x86.msi安装步骤# 1. 下载 MSI 安装包 Invoke-WebRequest -Uri https://github.com/PowerShell/PowerShell/releases/latest/download/PowerShell-7.x-win-x64.msi -OutFile PSInstaller.msi # 2. 静默安装 msiexec /i PSInstaller.msi /quiet # 3. 验证安装 pwsh --version方法3使用 wingetWindows 11推荐# 安装最新版本 winget install Microsoft.PowerShell # 查看安装状态 winget list PowerShell # 升级已安装的 PowerShell winget upgrade PowerShell方法4使用 Chocolatey软件包管理器# 先安装 Chocolatey Set-ExecutionPolicy Bypass -Scope Process -Force [System.Net.ServicePointManager]::SecurityProtocol [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 iex ((New-Object System.Net.WebClient).DownloadString(https://community.chocolatey.org/install.ps1)) # 然后安装 PowerShell choco install powershell-core -y⚠️ 重要提示启用执行策略如果运行脚本时遇到权限错误需要先修改执行策略# 以管理员身份运行 PowerShell # 查看当前执行策略 Get-ExecutionPolicy # 改为 RemoteSigned推荐 Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # 确认更改 Get-ExecutionPolicy二、Linux 系统安装Ubuntu/Debian# 安装依赖 wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb # 更新并安装 PowerShell sudo apt-get update sudo apt-get install -y powershellCentOS/RHEL/Fedora# RHEL/CentOS 8 curl -sSL https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm | sudo rpm -ivh sudo dnf install -y powersecl # Fedora curl -sSL https://packages.microsoft.com/config/fedora/39/packages-microsoft-prod.rpm | sudo rpm -ivh sudo dnf install -y powershellopenSUSE/SLES# openSUSE Leap 15.x sudo zypper ar https://packages.microsoft.com/yumrepos/powershell7-rpm.repo microsoft-repo sudo zypper refresh sudo zypper in powershell # SUSE Linux Enterprise Server sudo Zypper addrepo https://packages.microsoft.com/yumrepos/powershell7-rpm.repo MicrosoftRepo sudo zypper ref sudo zypper in powershellArch Linux# 从 AUR 安装使用 yay 或 paru yay -S powershell-bin # 或使用 pacman # 注意可能需要先添加 AUR 源三、macOS 系统安装方法1使用 Homebrew推荐⭐# 安装 Homebrew如未安装 /bin/bash -c $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) # 安装 PowerShell brew install --cask powershell # 验证安装 pwsh --version方法2下载PKG安装包访问 https://github.com/PowerShell/PowerShell/releases/latest下载powershell-X.X.X-osx-x64.pkg双击运行并完成安装方法3使用 MacPorts# 安装 MacPorts # 然后安装 PowerShell sudo port install powershell7四、验证安装# 所有系统通用 pwsh --version # 查看详细信息 $PSVersionTable.PSVersion $PSVersionTable.PSEdition $PSVersionTable.OS预期输出示例7.4.5 # PowerShell 版本 Core # Edition Darwin # OS (macOS) / Linux / WinNT (Windows)五、常见问题解决❗ 问题1:pwsh命令找不到# Windows: 添加到环境变量 PATH # Linux/macOS: 创建符号链接 ln -s /usr/local/bin/pwsh /usr/bin/pwsh❗ 问题2: 执行策略限制# 临时允许执行当前目录的脚本 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser # 永久生效需管理员 Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine❗ 问题3: .NET Framework 依赖缺失# Linux 上可能需要的依赖 sudo apt-get install -y dotnet-hostfxr-8.0六、卸载 PowerShellWindows# 通过设置→应用和功能 # 或使用命令行 Remove-Item C:\Program Files\PowerShell\* -Recurse -ForcemacOS# 移除 Homebrew 安装 brew uninstall --cask powershell # 手动删除 sudo rm -rf /usr/local/bin/pwsh sudo rm -rf /Applications/Microsoft\ PowerShellLinux# Debian/Ubuntu sudo apt-get remove powershell # CentOS/RHEL sudo dnf remove powershell # 清理配置文件 sudo rm -rf /etc/powershell七、升级 PowerShellWindows (winget)winget upgrade PowerShellmacOS (Homebrew)brew upgrade --cask powershellLinux# Ubuntu/Debian sudo apt-get update sudo apt-get upgrade powershell # CentOS/RHEL sudo dnf upgrade powershell八、推荐的后续操作# 1. 测试基本功能 Write-Host 欢迎使用 PowerShell! -ForegroundColor Green Get-Service | Select-Object Name, Status # 2. 安装 VS Code PowerShell 扩展代码编辑 # 3. 探索模块 Install-Module PSReadLine # 4. 学习资源 Get-Help about_ Get-Command | Measure-Object | Select-Object Count 安装方式对比表方法WindowsLinuxmacOS难度推荐度Microsoft Store✅❌❌⭐⭐⭐⭐⭐⭐MSI 安装包✅❌❌⭐⭐⭐⭐⭐⭐⭐Homebrew❌❌✅⭐⭐⭐⭐⭐⭐⭐winget✅❌❌⭐⭐⭐⭐⭐⭐Chocolatey✅❌❌⭐⭐⭐⭐⭐⭐⭐官方仓库✅✅✅⭐⭐⭐⭐⭐⭐⭐下载PKG✅❌✅⭐⭐⭐⭐⭐⭐✅ 完成以上任一方法后你就可以开始使用 PowerShell 进行系统管理和自动化任务了如需了解具体用法可以继续提问❤️❤️❤️本人水平有限如有纰漏欢迎各位大佬评论批评指正如果觉得这篇文对你有帮助的话也请给个点赞、收藏下吧非常感谢! Stay Hungry Stay Foolish 道阻且长,行则将至,让我们一起加油吧