Get-InstalledPSResource
通过 PowerShellGet返回计算机上安装的模块和脚本。
语法
Get-InstalledPSResource
[[-Name] <String[]>]
[-Version <String>]
[-Path <String>]
[-Scope <ScopeType>]
[<CommonParameters>]
说明
此 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.0
和 2.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
的别名。