共用方式為


Get-InstalledPSResource

透過 PowerShellGet傳回電腦上安裝的模組和腳本。

語法

Get-InstalledPSResource
   [[-Name] <String[]>]
   [-Version <String>]
   [-Path <String>]
   [-Scope <ScopeType>]
   [<CommonParameters>]

Description

此 Cmdlet 會搜尋模組和腳本安裝路徑,並傳回 PSResourceInfo 對象,這些物件會描述找到的每個資源專案。 這相當於 Get-InstalledModule v2 中 Get-InstalledScript Cmdlet 的合併輸出。

範例

範例 1

此範例會傳回電腦上安裝的所有模組和腳本版本。

Get-InstalledPSResource

範例 2

此範例會傳回使用 PowerShellGet安裝的所有 Az 模組版本。

Get-InstalledPSResource Az

範例 3

本範例會傳回目前目錄中所安裝 Az 模組的所有版本。

Get-InstalledPSResource Az -Path .

範例 4

如果已在系統上安裝 Az 模組,本範例會傳回特定版本的 Az 模組。

Get-InstalledPSResource Az -Version 9.4.0

範例 5

本範例會傳回指定版本範圍內所有已安裝的 Az 模組版本。

Get-InstalledPSResource Az -Version "(1.0.0, 3.0.0)"

範例 6

本範例會在系統上安裝 PowerShellGet 模組時,傳回特定的預覽版本。

Get-InstalledPSResource PowerShellGet -Version 3.0.19-beta19

Name          Version Prerelease Repository Description
----          ------- ---------- ---------- -----------
PowerShellGet 3.0.19  beta19     PSGallery  PowerShell module with commands for discovering, installing, updating and p…

範例 6

上述範例顯示已在系統上安裝 PowerShellGet 3.0.14-beta14 版。 此範例顯示您必須提供完整版本,包括 發行前版本 標籤,以 版本來識別已安裝的模組。

Get-InstalledPSResource PowerShellGet -Version 3.0.19

此命令沒有輸出。

範例 7

在此範例中,您會看到系統上已安裝四個 PSReadLine 版本。 第二個命令會搜尋 2.2.02.3.0之間的版本範圍。

Get-InstalledPSResource PSReadLine

Name       Version Prerelease Repository Description
----       ------- ---------- ---------- -----------
PSReadLine 2.3.0   beta0      PSGallery  Great command line editing in the PowerShell console host
PSReadLine 2.2.6              PSGallery  Great command line editing in the PowerShell console host
PSReadLine 2.2.5              PSGallery  Great command line editing in the PowerShell console host
PSReadLine 2.2.2              PSGallery  Great command line editing in the PowerShell console host
PSReadLine 2.2.0   beta4      PSGallery  Great command line editing in the PowerShell console host

Get-InstalledPSResource PSReadLine -Version '[2.2.0, 2.3.0]'

Name       Version Prerelease Repository Description
----       ------- ---------- ---------- -----------
PSReadLine 2.3.0   beta0      PSGallery  Great command line editing in the PowerShell console host
PSReadLine 2.2.6              PSGallery  Great command line editing in the PowerShell console host
PSReadLine 2.2.5              PSGallery  Great command line editing in the PowerShell console host
PSReadLine 2.2.2              PSGallery  Great command line editing in the PowerShell console host

根據 NuGet 版本規則,發行前版本小於穩定版本,因此 2.2.0-beta4 小於指定版本範圍內的 2.2.0 版本。

參數

-Name

要尋找的資源名稱。 支援通配符,但 NuGet 只接受 * 字元。 NuGet 不支援本機 (檔案型) 存放庫的通配符搜尋。

類型:String[]
Position:0
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:True

-Path

指定要搜尋的路徑。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Scope

指定資源的範圍。

類型:Microsoft.PowerShell.PSResourceGet.UtilClasses.ScopeType
接受的值:CurrentUser, AllUsers
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Version

指定要傳回的資源版本。 此值可以是使用 NuGet 版本設定語法的確切版本或版本範圍。

如需 NuGet 版本範圍的詳細資訊,請參閱 套件版本設定

PowerShellGet 支援 NuGet 版本範圍檔中所列 最低內含版本。 使用 1.0.0.0,因為版本不會產生 1.0.0.0 版和更新版本(最小內含範圍)。 相反地,此值會被視為必要的版本。 若要搜尋最小內含範圍,請使用 [1.0.0.0, ] 作為版本範圍。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:True

輸入

String[]

輸出

Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo

備註

模組會將 Get-PSResource 定義為 Get-InstalledPSResource的別名。