Find-Module
查找与指定条件匹配的存储库中的模块。
语法
Find-Module
[[-Name] <string[]>]
[-MinimumVersion <string>]
[-MaximumVersion <string>]
[-RequiredVersion <string>]
[-AllVersions]
[-IncludeDependencies]
[-Filter <string>]
[-Tag <string[]>]
[-Includes <string[]>]
[-DscResource <string[]>]
[-RoleCapability <string[]>]
[-Command <string[]>]
[-Proxy <uri>]
[-ProxyCredential <pscredential>]
[-Repository <string[]>]
[-Credential <pscredential>]
[-AllowPrerelease]
[<CommonParameters>]
说明
该 Find-Module
cmdlet 查找与指定条件匹配的存储库中的模块。
Find-Module
为找到的每个模块返回 PSRepositoryItemInfo 对象。 可以将对象向下发送到 cmdlet,例如 Install-Module
。
这是 Microsoft.PowerShell.PSResourceGet 中 cmdlet 的代理 cmdletFind-PSResource
。 有关详细信息,请参阅 Find-PSResource。
示例
示例 1:按名称查找模块
此示例在默认存储库中找到一个模块。
Find-Module -Name PowerShellGet
Version Name Repository Description
------- ---- ---------- -----------
2.1.0 PowerShellGet PSGallery PowerShell module with commands for discovering...
该 Find-Module
cmdlet 使用 Name 参数指定 PowerShellGet 模块。
示例 2:查找具有类似名称的模块
此示例使用星号 (*
) 通配符查找具有类似名称的模块。
Find-Module -Name PowerShell*
Version Name Repository Description
------- ---- ---------- -----------
0.4.0 powershell-yaml PSGallery Powershell module for serializing and...
2.1.0 PowerShellGet PSGallery PowerShell module with commands for...
1.9 Powershell.Helper.Extension PSGallery # Powershell.Helper.Extension...
3.1 PowerShellHumanizer PSGallery PowerShell Humanizer wraps Humanizer...
4.0 PowerShellISEModule PSGallery a module that adds capability to the ISE
该 Find-Module
cmdlet 使用 Name 参数和星号 (*
) 通配符查找包含 PowerShell 的所有模块。
示例 3:按最低版本查找模块
此示例搜索模块的最低版本。 如果存储库包含较新版本的模块,则返回较新版本。
Find-Module -Name PowerShellGet -MinimumVersion 1.6.5
Version Name Repository Description
------- ---- ---------- -----------
2.1.0 PowerShellGet PSGallery PowerShell module with commands for discovering...
该 Find-Module
cmdlet 使用 Name 参数指定 PowerShellGet 模块。
MinimumVersion 指定版本 1.6.5。
Find-Module
返回 PowerShellGet 版本 2.1.0 ,因为它超出了最低版本,并且是最新版本。
示例 4:按特定版本查找模块
此示例演示如何安装模块的特定预发行版。 预发行版本的格式为 <version_number>-<prerelease_label>
.
Find-Module PSReadLine -AllowPrerelease -RequiredVersion 2.2.4-beta1
Version Name Repository Description
------- ---- ---------- -----------
2.2.4-beta1 PSReadLine PSGallery Great command line editing in the PowerS…
示例 5:在特定存储库中查找模块
此示例使用 Repository 参数查找特定存储库中的模块。
Find-Module -Name PowerShellGet -Repository PSGallery
Version Name Repository Description
------- ---- ---------- -----------
2.1.0 PowerShellGet PSGallery PowerShell module with commands for discovering...
该 Find-Module
cmdlet 使用 Name 参数指定 PowerShellGet 模块。
Repository 参数指定搜索 PSGallery 存储库。
示例 6:在多个存储库中查找模块
此示例使用指定 Register-PSRepository
存储库。
Find-Module
使用存储库搜索模块。
Register-PSRepository -Name MySource -SourceLocation https://www.myget.org/F/powershellgetdemo/
Find-Module -Name Contoso* -Repository PSGallery, MySource
Repository Version Name Description
---------- ------- ---- -----------
PSGallery 2.0.0.0 ContosoServer Cmdlets and DSC resources for managing Contoso Server...
MySource 1.2.0.0 ContosoClient Cmdlets and DSC resources for managing Contoso Client...
该 Register-PSRepository
cmdlet 注册新的存储库。
Name 参数分配名称 MySource。
SourceLocation 参数指定存储库的地址。
cmdlet Find-Module
使用 带 星号 (*
) 通配符的 Name 参数来指定 Contoso 模块。
Repository 参数指定搜索两个存储库:PSGallery 和 MySource。
示例 7:查找包含 DSC 资源的模块
此命令返回包含 DSC 资源的模块。 Includes 参数具有四个预定义的功能,用于搜索存储库。 使用 Tab-complete 显示 Includes 参数支持的四个功能。
Find-Module -Repository PSGallery -Includes DscResource
Version Name Repository Description
------- ---- ---------- -----------
2.7.0 Carbon PSGallery Carbon is a PowerShell module...
8.5.0.0 xPSDesiredStateConfiguration PSGallery The xPSDesiredStateConfiguration module...
1.3.1 PackageManagement PSGallery PackageManagement (a.k.a. OneGet) is...
2.7.0.0 xWindowsUpdate PSGallery Module with DSC Resources...
3.2.0.0 xCertificate PSGallery This module includes DSC resources...
3.1.0.0 xPowerShellExecutionPolicy PSGallery This DSC resource can change the user...
该 Find-Module
cmdlet 使用 Repository 参数搜索存储库 PSGallery。
Includes 参数指定 DscResource,这是参数可以在存储库中搜索的功能。
示例 8:使用筛选器查找模块
在此示例中,若要查找模块,将使用筛选器来搜索存储库。
对于基于 NuGet 的存储库, Filter 参数通过参数的名称、说明和标记进行搜索。
Find-Module -Filter AppDomain
Version Name Repository Description
------- ---- ---------- -----------
1.0.0.0 AppDomainConfig PSGallery Manipulate AppDomain configuration...
1.1.0 ClassExplorer PSGallery Quickly search the AppDomain for classes...
该 Find-Module
cmdlet 使用 Filter 参数搜索 AppDomain 的存储库。
示例 9:按标记查找模块
此示例演示如何按标记查找模块。 该值 CrescendoBuilt
是自动添加到使用 Microsoft.PowerShell.Crescendo 模块创建的模块的标记。
Find-Module -Tag CrescendoBuilt
Version Name Repository Description
------- ---- ---------- -----------
0.1.0 Foil PSGallery A PowerShell Crescendo wrapper for Chocolatey
0.3.1 Cobalt PSGallery A PowerShell Crescendo wrapper for WinGet
1.1.0 SysInternals PSGallery PowerShell cmdlets for SysInternal tools
0.0.4 Croze PSGallery A PowerShell Crescendo wrapper for Homebrew
0.0.2 AptPackage PSGallery PowerShell Crescendo-generated Module to query APT-Package Information
1.0.1 RoboCopy PSGallery PowerShell cmdlet for the official RoboCopy.exe
1.0.2 TShark PSGallery PowerShell cmdlet for tshark.exe
1.0.0 SpeedTestCLI PSGallery PowerShell cmdlets speedtest-cli
1.0.0 SpeedTest-CLI PSGallery PowerShell cmdlets for Internet Speed Test
1.0.2 Image2Text PSGallery PowerShell Images into ASCII art
0.1.1 Quser.Crescendo PSGallery This module displays session information of users logged onto a local or remote m...
1.0.2 Takeown PSGallery Crescendo Powershell wrapper of takeown.exe
参数
-AllowPrerelease
包括在标记为预发行的结果模块中。
代理 cmdlet 将此参数映射到 预发行版 参数 Find-PSResource
。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-AllVersions
指定在结果中包含模块的所有版本。 不能将 AllVersions 参数与 MinimumVersion、 MaximumVersion 或 RequiredVersion 参数一起使用。
代理 cmdlet 在调用Find-PSResource
前将此参数-Version *
转换为此参数。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Command
代理 cmdlet 忽略此参数,因为 NameParameterSet 不支持 Find-PSResource
此参数。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Credential
指定有权为指定的包提供程序或源安装模块的用户帐户。
类型: | PSCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-DscResource
代理 cmdlet 忽略此参数,因为 NameParameterSet 不支持 Find-PSResource
此参数。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Filter
代理 cmdlet 忽略此参数,因为 NameParameterSet 不支持 Find-PSResource
此参数。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-IncludeDependencies
指示此作包括依赖于 Name 参数中指定的模块的所有模块。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Includes
代理 cmdlet 忽略此参数,因为 NameParameterSet 不支持 Find-PSResource
此参数。
类型: | String[] |
接受的值: | DscResource, Cmdlet, Function, RoleCapability |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-MaximumVersion
代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Version 参数 Find-PSResource
一起使用。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-MinimumVersion
代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Version 参数 Find-PSResource
一起使用。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Name
指定要在存储库中搜索的模块的名称。 接受以逗号分隔的模块名称列表。 可以使用通配符。
类型: | String[] |
Position: | 0 |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | True |
-Proxy
代理 cmdlet 忽略此参数,因为 NameParameterSet 不支持 Find-PSResource
此参数。
类型: | Uri |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-ProxyCredential
代理 cmdlet 忽略此参数,因为 NameParameterSet 不支持 Find-PSResource
此参数。
类型: | PSCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Repository
使用 Repository 参数指定要搜索模块的存储库。 注册多个存储库时使用。 接受以逗号分隔的存储库列表。 若要注册存储库,请使用 Register-PSRepository
。 若要显示已注册的存储库,请使用 Get-PSRepository
。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RequiredVersion
代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Version 参数 Find-PSResource
一起使用。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-RoleCapability
代理 cmdlet 忽略此参数,因为 NameParameterSet 不支持 Find-PSResource
此参数。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Tag
指定一个标签数组。 示例标记包括 DesiredStateConfiguration、 DSC、 DSCResourceKit 或 PSModule。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
String[]
输出
PSRepositoryItemInfo
Find-Module
创建可将管道发送到 cmdlet 的 PSRepositoryItemInfo 对象,例如 Install-Module
。
备注
PowerShell 包含以下与 Find-Module
相关的别名:
- 所有平台:
fimo
PowerShell 库不再支持传输层安全性(TLS)版本 1.0 和 1.1。 必须使用 TLS 1.2 或更高版本。 使用以下命令确保使用的是 TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12