共用方式為


具有相容 PowerShell 版本或作業系統的套件

從 5.1 版開始,PowerShell 提供代表各種功能集及平台相容性的不同版本。

透過 PowerShell 版本搜尋

PowerShell 的兩個版本為:

  • Desktop Edition: 建置在 .NET Framework 上,與在完整使用量的 Windows 版本 (如 Server Core 和 Windows Desktop) 上執行的 PowerShell 指令碼和模組目標版本相容相容。
  • Core Edition: 建置在 .NET Core 上,與在降低使用量的 Windows 版本 (如 Nano Server 和 Windows IoT) 上執行的 PowerShell 指令碼和模組目標版本相容。

如果套件已指定相容的 PSEditions,則 PSEditions 會列為套件顯示頁面和套件結果中「PowerShell 版本」的一部分。 您也可以使用 PowerShell 來搜尋相容的套件。

含有 PSEditions 的項目顯示網頁

使用 Tags:"PSEdition_Desktop" 和 Tags:"PSEdition_Core" 篩選 PowerShell Gallery 上的套件。

使用 Tags:"PSEdition_Core" 來搜尋與 PowerShell Core 版本相容的項目

與 Core PSEdition 相容之項目的搜尋結果

使用 Tags:"PSEdition_Desktop" 來搜尋與 PowerShell Desktop 版本相容的項目

與 Desktop PSEdition 相容之項目的搜尋結果

使用 PowerShell 來搜尋套件以尋找相容的版本

您可以指定標籤來篩選 PowerShell 版本和 OS。 您可以使用 Find-Package Cmdlet,指定 -Tag 參數來指定您瞄準的目標版本 (和 OS)。 例如:

# Find modules compatible with PowerShell Core:
Find-Module -Tag PSEdition_Core

# Find modules compatible with PowerShell on Linux:
Find-Module -Tag PSEdition_Core, Linux

依作業系統搜尋

由於 PowerShell 適用於 Windows、Linux 和 MacOS,因此資源庫中的套件可能設計為這些操作系統的任何組合。 在資源庫 UI 中,使用下列搜尋標籤來尋找作業系統所標記的套件:

  • 標籤:"Windows"
  • 標籤:"Linux"
  • 標籤:"MacOS"

您可以在 Find-Module (以及其他 PowerShellGet 模組中的 Cmdlet) 上指定這些標籤,例如:

# Find Modules compatible with Windows
Find-Module -Tag Linux

搜尋多個相容性

您可以使用此語法,尋找具有多個相容性的套件:

標籤:"Compatibility1" "Compatibility2"

例如,如果您要尋找在 Windows 和 Linux 電腦上執行的套件,請使用搜尋標籤:

標籤:"PSEdition_Core" "Windows" "Linux"

若要使用 PowerShell 搜尋,您可以使用 Find-Module (以及 PowerShellGet 模組中的其他 Cmdlet),例如:

# Find scripts compatible with PowerShell, Windows, and Linux
Find-Script -Tag PSEdition_Core,Linux,Windows

# Find modules compatible with PowerShell and MacOS
Find-Module -Tag PSEdition_Core,MacOS

撰寫和尋找與 PowerShell 版本相容之套件的詳細資訊