共用方式為


Find-PSResource

根據名稱或其他套件屬性,從存放庫 (本機或遠端) 搜尋套件。

Syntax

Find-PSResource
    [[-Name] <String[]>]
    [-Type <ResourceType>]
    [-Version <String>]
    [-Prerelease]
    [-Tag <String[]>]
    [-Repository <String[]>]
    [-Credential <PSCredential>]
    [-IncludeDependencies]
    [<CommonParameters>]
Find-PSResource
    [-Prerelease]
    -CommandName <String[]>
    [-Repository <String[]>]
    [-Credential <PSCredential>]
    [<CommonParameters>]
Find-PSResource
    [-Prerelease]
    -DscResourceName <String[]>
    [-Repository <String[]>]
    [-Credential <PSCredential>]
    [<CommonParameters>]

Description

Cmdlet 會 Find-PSResource 根據名稱或其他套件屬性,從存放庫 (本機或遠端) 搜尋套件。

範例

範例 1

此範例會搜尋 powerShellGet 套件 PowerShell 資源庫。 Cmdlet 會傳回最高的非發行前版本。

Find-PSResource -Name PowerShellGet -Repository PSGallery

Name          Version Prerelease Repository Description
----          ------- ---------- ---------- -----------
PowerShellGet 2.2.5              PSGallery  PowerShell module with commands for discovering, installing, updating and p…

範例 2

此範例會 PowerShell 資源庫 搜尋 PowerShellGet 套件,包括發行前版本。

Find-PSResource -Name PowerShellGet -Repository PSGallery -Prerelease

Name          Version Prerelease Repository Description
----          ------- ---------- ---------- -----------
PowerShellGet 3.0.21  beta21     PSGallery  PowerShell module with commands for discovering, installing, updating and p…

範例 3

此範例會搜尋 microsoft.PowerShell.SecretManagement 套件 PowerShell 資源庫。 Cmdlet 會傳回滿足指定 之 Version 範圍的所有版本。

$parameters = @{
    Name = 'Microsoft.PowerShell.SecretManagement'
    Version = '(0.9.0.0, 1.2.0.0]'
    Repository = 'PSGallery'
    Prerelease = $true
}
Find-PSResource @parameters

Name                                  Version Prerelease Repository Description
----                                  ------- ---------- ---------- -----------
Microsoft.PowerShell.SecretManagement 1.1.2              PSGallery  …
Microsoft.PowerShell.SecretManagement 1.1.1              PSGallery  …
Microsoft.PowerShell.SecretManagement 1.1.0   preview2   PSGallery  …
Microsoft.PowerShell.SecretManagement 1.1.0   preview    PSGallery  …
Microsoft.PowerShell.SecretManagement 1.1.0              PSGallery  …
Microsoft.PowerShell.SecretManagement 1.0.1              PSGallery  …
Microsoft.PowerShell.SecretManagement 1.0.0              PSGallery  …
Microsoft.PowerShell.SecretManagement 0.9.1              PSGallery  …

範例 4

此範例會搜尋包含 CommandName 的所有 Get-TargetResource模組資源。 Cmdlet 會傳回包含 命令的所有模組資源。

Find-PSResource -CommandName Get-TargetResource -Repository PSGallery

Name                 Package Name               Version
----                 ------------               -------
{Get-TargetResource} cRegFile                   1.2
{Get-TargetResource} cVNIC                      1.0.0.0
{Get-TargetResource} cWindowsErrorReporting     1.1
{Get-TargetResource} OctopusDSC                 4.0.1131
{Get-TargetResource} supVsts                    1.1.17.0
{Get-TargetResource} SystemLocaleDsc            1.2.0.0
{Get-TargetResource} WindowsDefender            1.0.0.4
{Get-TargetResource} xInternetExplorerHomePage  1.0.0
{Get-TargetResource} xPowerShellExecutionPolicy 3.1.0.0

範例 5

此範例會搜尋包含 DSC 資源 的所有模組資源 SystemLocale

Find-PSResource -DscResourceName SystemLocale -Repository PSGallery

Name           Package Name          Version
----           ------------          -------
{SystemLocale} ComputerManagementDsc 9.0.0
{SystemLocale} SystemLocaleDsc       1.2.0.0

範例 6

此範例會搜尋所有已註冊的 PSResourceRepositories 中名稱開頭 Computer為 的資源。

Find-PSResource -Name Computer*

Name                                              Version Prerelease Repository Description
----                                              ------- ---------- ---------- -----------
ComputerManagementDsc                             9.0.0              PSGallery  DSC resources for configuration of a Wi…
ComputerManagement                                1.1.2.3            PSGallery  A PowerShell module for working with th…
ComputerCleanup                                   1.2.0              PSGallery  Module for freeing up disk space / remo…
Computer_UnjoinDomainAndJoinWorkgroup_Config      1.0.0              PSGallery  This example switches the computer 'Ser…
Computer_SetComputerDescriptionInWorkgroup_Config 1.0.0              PSGallery  This example will set the computer desc…
Computer_RenameComputerInWorkgroup_Config         1.0.0              PSGallery  This example will set the machine name …
Computer_RenameComputerInDomain_Config            1.0.0              PSGallery  This example will change the machines n…
Computer_RenameComputerAndSetWorkgroup_Config     1.0.0              PSGallery  This configuration will set the compute…
Computer_JoinDomainSpecifyingDC_Config            1.0.0              PSGallery  This configuration sets the machine nam…
Computer_JoinDomain_Config                        1.0.0              PSGallery  This configuration sets the machine nam…

範例 7

此範例示範如何依標記尋找模組。 值 CrescendoBuilt 是標記,會自動新增至使用 Microsoft.PowerShell.Crescendo 模組建立的模組。

Find-PSResource -Tag CrescendoBuilt

Name            Version Prerelease Repository Description
----            ------- ---------- ---------- -----------
AptPackage      0.0.2              PSGallery  PowerShell Crescendo-generated Module to query APT-Package Information
Cobalt          0.4.0              PSGallery  A PowerShell Crescendo wrapper for WinGet
Croze           0.0.5              PSGallery  A PowerShell Crescendo wrapper for Homebrew
Foil            0.3.0              PSGallery  A PowerShell Crescendo wrapper for Chocolatey
Image2Text      1.0.2              PSGallery  PowerShell Images into ASCII art
pastel          1.0.1              PSGallery  PowerShell commands for pastel
PSDupes         0.0.1              PSGallery  A crescendo module to locate duplicate files. Very fast and easy to use, …
psFilesCli      0.0.3              PSGallery  A PowerShell wrapper for files-cli.exe
PSLogParser     0.0.2              PSGallery  Crescendo Powershell module for Log Parser 2.2
Quser.Crescendo 0.1.3              PSGallery  This module displays session information of users logged onto a local or …
RoboCopy        1.0.1              PSGallery  PowerShell cmdlet for the official RoboCopy.exe
SpeedTest-CLI   1.0.1              PSGallery  PowerShell cmdlets for Internet Speed Test
SpeedTestCLI    1.0.0              PSGallery  PowerShell cmdlets speedtest-cli
SysInternals    1.1.0              PSGallery  PowerShell cmdlets for SysInternal tools
Takeown         1.0.2              PSGallery  Crescendo Powershell wrapper of takeown.exe
TShark          1.0.2              PSGallery  PowerShell cmdlet for tshark.exe
VssAdmin        0.8.0              PSGallery  This is a Crescendo module to wrap the Windows `vssadmin.exe` command-lin…

參數

-CommandName

要搜尋的命令名稱。

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

-Credential

存取存放庫時要使用的選擇性認證。

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

-DscResourceName

要搜尋的 DSC 資源名稱。

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

-IncludeDependencies

指定時,搜尋會傳回其相依性的所有相符資源。 重複資料刪除相依性。

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

-Name

要尋找的資源名稱。 支援通配符,但 NuGet 只接受 * 字元。 NuGet 不支援本機 (檔案型) 存放庫的通配符搜尋。

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

-Prerelease

指定時,會在傳回的搜尋結果中包含發行前版本。

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

-Repository

指定要搜尋的一或多個存放庫名稱。 如果未指定,搜尋會依優先順序包含所有已註冊的存放庫, (最高的第一個) ,直到找到包含套件的存放庫為止。 存放庫會依優先順序排序,然後依名稱排序。 優先順序較低的值具有較高的優先順序。

在多個存放庫之間搜尋資源時, PSResourceGet Cmdlet 會使用此排序順序來搜尋存放庫。 Find-PSResource 會從已排序的存放庫清單中傳回所有相符的套件。

參數支援 * 通配符。 如果您指定多個存放庫,則所有名稱都必須包含或省略通配符。 您無法指定名稱與沒有通配符的混合。

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

-Tag

篩選包含指定標籤的資源搜尋結果。 如果指定了多個標籤,Cmdlet 只會傳回包含提供之所有標記的資源。

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

-Type

指定要尋找的一或多個資源類型。 支援的資源類型包括:

  • None
  • Module
  • Script
Type:Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceType
Accepted values:None, Module, Script
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Version

指定要傳回的資源版本。 此值可以是使用 NuGet 版本設定語法的確切版本或版本範圍。

支援通配符,但 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

Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCommandResourceInfo

備註

模組會將 fdres 定義為 的 Find-PSResource別名。