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>]

说明

cmdlet Find-Module 在存储库中查找与指定条件匹配的模块。 Find-Module 为其找到的每个模块返回 一个 PSRepositoryItemInfo 对象。 对象可以在管道中向下发送到 cmdlet,例如 Install-Module

这是 Microsoft.PowerShell.PSResourceGet 中 cmdlet 的代理 Find-PSResource cmdlet。 有关详细信息,请参阅 Find-PSResource

示例

示例 1:按名称查找模块

此示例在默认存储库中查找模块。

Find-Module -Name PowerShellGet

Version   Name              Repository           Description
-------   ----              ----------           -----------
2.1.0     PowerShellGet     PSGallery            PowerShell module with commands for discovering...

cmdlet Find-Module 使用 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

cmdlet Find-Module 使用带有星号的 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...

cmdlet Find-Module 使用 Name 参数指定 PowerShellGet 模块。 MinimumVersion 指定版本 1.6.5Find-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...

cmdlet Find-Module 使用 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...

cmdlet Register-PSRepository 注册新的存储库。 Name 参数分配名称 MySourceSourceLocation 参数指定存储库的地址。

cmdlet Find-Module 使用带有星号的 Name 参数 (*) 通配符来指定 Contoso 模块。 Repository 参数指定搜索两个存储库:PSGalleryMySource

示例 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...

cmdlet Find-Module 使用 Repository 参数搜索存储库 PSGalleryIncludes 参数指定 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...

cmdlet Find-Module 使用 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-PSResourcePrerelease 参数。

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

-AllVersions

指定在结果中包含模块的所有版本。 不能将 AllVersions 参数与 MinimumVersion、MaximumVersionRequiredVersion 参数一起使用。

代理 cmdlet 在调用 Find-PSResource之前将-Version *此参数转换为 。

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

-Command

代理 cmdlet 忽略此参数,因为 的 NameParameterSetFind-PSResource不支持此参数。

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

-Credential

指定有权为指定的包提供程序或源安装模块的用户帐户。

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

-DscResource

代理 cmdlet 忽略此参数,因为 的 NameParameterSetFind-PSResource不支持此参数。

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

-Filter

代理 cmdlet 忽略此参数,因为 的 NameParameterSetFind-PSResource不支持此参数。

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

-IncludeDependencies

指示此操作包括依赖于 Name 参数中指定的模块的所有模块。

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

-Includes

代理 cmdlet 忽略此参数,因为 的 NameParameterSetFind-PSResource不支持此参数。

Type:String[]
Accepted values:DscResource, Cmdlet, Function, RoleCapability
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MaximumVersion

代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Find-PSResourceVersion 参数一起使用。

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

-MinimumVersion

代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Find-PSResourceVersion 参数一起使用。

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

-Name

指定要在存储库中搜索的模块的名称。 接受以逗号分隔的模块名称列表。 可以使用通配符。

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

-Proxy

代理 cmdlet 忽略此参数,因为 的 NameParameterSetFind-PSResource不支持此参数。

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

-ProxyCredential

代理 cmdlet 忽略此参数,因为 的 NameParameterSetFind-PSResource不支持此参数。

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

-Repository

使用 Repository 参数指定要搜索模块的存储库。 注册多个存储库时使用。 接受以逗号分隔的存储库列表。 若要注册存储库,请使用 Register-PSRepository。 若要显示已注册的存储库,请使用 Get-PSRepository

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

-RequiredVersion

代理 cmdlet 使用此参数的值来创建 NuGet 版本搜索字符串,以便与 Find-PSResourceVersion 参数一起使用。

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

-RoleCapability

代理 cmdlet 忽略此参数,因为 的 NameParameterSetFind-PSResource不支持此参数。

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

-Tag

指定标记的数组。 示例标记包括 DesiredStateConfigurationDSCDSCResourceKitPSModule

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

输入

String[]

String

Uri

PSCredential

输出

PSRepositoryItemInfo

Find-Module 创建 PSRepositoryItemInfo 对象,这些对象可在管道中向下发送到 cmdlet,例如 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