Find-Module

在符合指定準則的存放庫中尋找模組。

Syntax

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

Description

Cmdlet Find-Module 會在符合指定準則的存放庫中尋找模組。 Find-Module 會針對所找到的每個模組,傳回 PSRepositoryItemInfo 物件。 物件可以將管線向下傳送至 Cmdlet,例如 Install-Module

這是Microsoft.PowerShell.PSResourceGet中 Cmdlet 的 Proxy Cmdlet Find-PSResource 。 如需詳細資訊,請參閱 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.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:在特定存放庫中尋找模組

此範例會使用 存放庫 參數來尋找特定存放庫中的模組。

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參數會指派MySource名稱。 SourceLocation參數會指定存放庫的位址。

Cmdlet Find-Module 會使用 Name 參數搭配星號 () * 萬用字元來指定 Contoso 模組。 Repository參數會指定搜尋兩個存放庫PSGalleryMySource

範例 7:尋找包含 DSC 資源的模組

此命令會傳回包含 DSC 資源的模組。 Include參數有四個預先定義的功能,可用來搜尋存放庫。 使用 Tab-complete 來顯示 Include 參數支援的四個功能。

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 參數來搜尋 存放庫 PSGalleryInclude參數會指定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

包含在標示為發行前版本的結果模組中。

Proxy Cmdlet 會將此參數對應至 的 Find-PSResource發行前版本參數。

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

-AllVersions

指定在結果中包含模組的所有版本。 您無法搭配MinimumVersionMaximumVersionRequiredVersion參數使用AllVersions參數。

Proxy Cmdlet 會在呼叫 Find-PSResource 之前,將此參數 -Version * 轉換成 。

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

-Command

Proxy 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

Proxy Cmdlet 會忽略此參數,因為 的 NameParameterSetFind-PSResource 不支援此參數。

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

-Filter

Proxy 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

Proxy 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

Proxy Cmdlet 會使用此參數的值來建立 NuGet 版本搜尋字串,以搭配 的 Find-PSResourceVersion參數使用。

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

-MinimumVersion

Proxy 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

Proxy Cmdlet 會忽略此參數,因為 的 NameParameterSetFind-PSResource 不支援此參數。

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

-ProxyCredential

Proxy Cmdlet 會忽略此參數,因為 的 NameParameterSetFind-PSResource 不支援此參數。

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

-Repository

使用 存放庫 參數指定要搜尋模組的存放庫。 註冊多個存放庫時使用。 接受以逗號分隔的存放庫清單。 若要註冊存放庫,請使用 Register-PSRepository 。 若要顯示已註冊的存放庫,請使用 Get-PSRepository

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

-RequiredVersion

Proxy Cmdlet 會使用此參數的值來建立 NuGet 版本搜尋字串,以搭配 的 Find-PSResourceVersion參數使用。

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

-RoleCapability

Proxy Cmdlet 會忽略此參數,因為 的 NameParameterSetFind-PSResource 不支援此參數。

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

-Tag

指定標記的陣列。 範例標籤包括DesiredStateConfigurationDSC、DSCResourceKitPSModule

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