Get-InstalledPSResource

通过 PowerShellGet 返回计算机上安装的模块和脚本。

语法

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

说明

此 cmdlet 搜索模块和脚本安装路径,并返回描述找到的每个资源项的 PSResourceInfo 对象。 这等效于 PowerShellGet v2 中 Get-InstalledModuleGet-InstalledScript cmdlet 的组合输出。

示例

示例 1

此示例返回计算机上安装的所有模块和脚本版本。

Get-InstalledPSResource

示例 2

此示例返回使用 PowerShellGet 安装的所有 Az 模块版本。

Get-InstalledPSResource Az

示例 3

此示例返回当前目录中安装的所有 Az 模块版本。

Get-InstalledPSResource Az -Path .

示例 4

此示例返回特定版本的 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.3.0之间的2.2.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 不支持对基于文件的本地 () 存储库进行通配符搜索。

Type:String[]
Position:0
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:True

-Path

指定要搜索的路径。

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Scope

指定资源的范围。

Type:Microsoft.PowerShell.PSResourceGet.UtilClasses.ScopeType
Accepted values:CurrentUser, AllUsers
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Version

指定要返回的资源的版本。 该值可以是使用 NuGet 版本控制语法的确切版本或版本范围。

有关 NuGet 版本范围的详细信息,请参阅 包版本控制

PowerShellGet 支持 NuGet 版本范围文档中列出的 所有非独占 版本。 使用 1.0.0.0 作为版本不会产生版本 1.0.0.0 和更高版本 (最小非独占范围) 。 相反,该值被视为所需的版本。 若要搜索最小非独占范围,请使用 [1.0.0.0, ] 作为版本范围。

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

输入

String[]

输出

Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo

备注

模块将 Get-PSResource 定义为 的 Get-InstalledPSResource别名。