
PowerShell 安裝指南Windows、Linux 與 macOS 三步就位【免費下載鏈接】PowerShellPowerShell for every system!項目地址: https://gitcode.com/GitHub_Trending/po/PowerShell剛接觸 PowerShell 的人最??ㄔ谌幇洛e了x64 的包拿到 ARM 機器上、裝完敲pwsh沒反應、不知道該不該手動配 PATH。這篇文章從確認本機架構(gòu)開始把一鍵腳本、手動裝包、驗證和常用配置整條路走一遍不再介紹項目背景。環(huán)境自檢先確認該下哪個包安裝包按「版本-系統(tǒng)-架構(gòu)」命名架構(gòu)選錯是最常見的坑。Linux 和 macOS 先跑一條命令看 CPU 架構(gòu)uname -m執(zhí)行后你會看到x86_64、aarch64這類輸出它直接決定下載包里該選哪個架構(gòu)段。Windows 上在現(xiàn)有 PowerShell 里查處理器[System.Environment]::Is64BitOperatingSystem執(zhí)行后你會看到True或FalseFalse說明是 32 位系統(tǒng)只能選 x86 的包。一鍵安裝腳本有 Windows PowerShell 就先用它在 Windows PowerShell 5.1 里跑這一行腳本會自動檢測系統(tǒng)、下載對應包并解包Invoke-Expression { $(Invoke-RestMethod https://aka.ms/install-powershell.ps1) }執(zhí)行完你會看到PowerShell has been installed at 安裝目錄的綠色提示目錄默認是%LOCALAPPDATA%\Microsoft\powershell。腳本本身放在 tools/install-powershell.ps1常用開關-Preview裝 preview 構(gòu)建目錄自動變成~/.powershell-preview和正式版并存-Destination C:\MyPowerShell指定安裝目錄不填就用默認路徑-AddToPathWindows 下寫入用戶 PATHLinux/macOS 下創(chuàng)建軟鏈接-DoNotOverwrite目錄已存在時直接報錯而不是覆蓋舊版本沒有 PowerShell 的 Linux/macOS 機器用 bash 版安裝器它會識別發(fā)行版并自動分流bash (curl -sL https://aka.ms/install-powershell.sh)執(zhí)行完它會自己跑一遍pwsh看到 Congratulations! PowerShell is installed 即代表成功。手動部署按系統(tǒng)選包手動裝包適合要固定版本、或不想跑腳本的場景。三個平臺的包命名規(guī)則一致Windows 是PowerShell-version-win-arch.msi/.zipLinux 是powershell-version-linux-x64.tar.gzmacOS 是powershell-version-osx-x64.tar.gz。手動部署 Windows 版MSI 雙擊即裝用命令行靜默安裝時msiexec /i PowerShell-version-win-x64.msi /quiet執(zhí)行后無輸出用pwsh -v驗證即可。手動部署 Linux 版解壓到固定目錄再建軟鏈接讓全局可用tar zxf powershell-version-linux-x64.tar.gz -C /opt/microsoft/powershell/7 sudo ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh執(zhí)行完軟鏈接建好后任何目錄下敲pwsh都能進入。手動部署 macOS 版有 Homebrew 的話走 cask 最省事brew install --cask powershell執(zhí)行后終端里直接出現(xiàn)PS提示符。沒有 Homebrew 時手動解包并鏈接tar zxf powershell-version-osx-x64.tar.gz -C /usr/local/powershell sudo ln -s /usr/local/powershell/pwsh /usr/local/bin/pwshPowerShell 在 macOS 上首次打開安裝包時出現(xiàn)的授權(quán)提示裝完第一件事驗證版本pwsh $PSVersionTable執(zhí)行后你會看到類似PSVersion 7.6.4、PSEdition Core的完整版本表倉庫當前記錄的穩(wěn)定版是 v7.6.4見 tools/metadata.json。進階調(diào)優(yōu)三個最常用的配置點裝模塊進當前用戶作用域不污染系統(tǒng)級Install-Module -Name PSReadLine -Scope CurrentUser執(zhí)行后再次啟動pwshGet-Module -ListAvailable PSReadLine能列出該模塊即成功。查實驗特性并臨時開啟當前倉庫列出的特性見 experimental-feature-linux.jsonGet-ExperimentalFeature Enable-ExperimentalFeature -Name PSFeedbackProvider執(zhí)行后你會看到帶Enabled True的特性行該開關只作用于當前會話。編輯啟動配置文件首次沒有文件時先New-Item $PROFILE -Forcecode $PROFILE踩坑與排查癥狀Linux 上pwsh: command not found。排查ls -l /usr/bin/pwsh。解決多半是軟鏈接沒建成回到「手動部署 Linux 版」重跑ln -s那一步或確認你有 sudo 權(quán)限。癥狀Windows 報處理器架構(gòu)不兼容。排查(Get-ComputerInfo -Property OsArchitecture).OsArchitecture。解決輸出 32 位就換win-x86包ARM 芯片換win-arm64包重裝前把舊目錄清掉。癥狀macOS 首次打開報無法驗證開發(fā)者。排查系統(tǒng)設置 → 隱私與安全性看是否提示被攔截。解決點仍要打開反復被攔時改用上面的 tar.gz 手動安裝路徑繞開 Gatekeeper 校驗。延伸入口項目文檔與構(gòu)建說明docs/命令行與 IDE 命令示例含截圖docs/cmdlet-example/各平臺安裝腳本源碼tools/install-powershell.ps1、tools/install-powershell.shPester 測試集test/powershell/pwsh【免費下載鏈接】PowerShellPowerShell for every system!項目地址: https://gitcode.com/GitHub_Trending/po/PowerShell創(chuàng)作聲明:本文部分內(nèi)容由AI輔助生成(AIGC),僅供參考