Find-Script
查找脚本。
语法
Default (默认值)
Find-Script
    [[-Name] <String[]>]
    [-MinimumVersion <String>]
    [-MaximumVersion <String>]
    [-RequiredVersion <String>]
    [-AllVersions]
    [-IncludeDependencies]
    [-Filter <String>]
    [-Tag <String[]>]
    [-Includes <String[]>]
    [-Command <String[]>]
    [-Proxy <Uri>]
    [-ProxyCredential <PSCredential>]
    [-Repository <String[]>]
    [-Credential <PSCredential>]
    [-AllowPrerelease]
    [<CommonParameters>]
说明
该 Find-Script cmdlet 在已注册的存储库中查找指定的脚本。
示例
示例 1:查找所有可用的脚本
Find-Script
此命令查找所有可用的脚本。
示例 2:按名称查找脚本
Find-Script -Name "Start-WFContosoServer"
此命令查找名为 Start-WFContosoServer 的脚本。
示例 3:按名称、所需版本和指定存储库查找脚本
Find-Script -Name "Required-Script2" -RequiredVersion 2.0 -Repository "LocalRepo01"
此命令在 LocalRepo01 存储库中按名称和所需版本查找脚本。
示例 4:查找脚本并将输出格式化为列表
Find-Script -Name "Required-Script2" -RequiredVersion 2.0 -Repository "LocalRepo1" | Format-List * -Force
此命令在 LocalRepo1 存储库中找到 Required-Script2,然后将生成的 PSRepositoryItemInfo 对象传递给 Format-List cmdlet。
示例 5:在指定的版本范围内查找脚本
Find-Script -Name "Required-Script2" -MinimumVersion 2.1 -MaximumVersion 2.5 -Repository "LocalRepo1"
Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
2.5        Required-Script2                    Script     LocalRepo1           Description for the Required-Script2 script
此命令查找 LocalRepo1 存储库中 2.1 和 2.5 版本之间的 RequiredScript2 的所有版本。
示例 6:查找脚本的所有版本
Find-Script -Name "Required-Script02" -AllVersions
Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
1.0        Required-Script2                    Script     LocalRepo1           Description for the Required-Script2 script
1.5        Required-Script2                    Script     LocalRepo1           Description for the Required-Script2 script
2.0        Required-Script2                    Script     LocalRepo1           Description for the Required-Script2 script
2.5        Required-Script2                    Script     LocalRepo1           Description for the Required-Script2 script
此命令查找 Required-Script02 的所有版本。
示例 7:查找脚本及其依赖项
Find-Script -Name "Script-WithDependencies1" -IncludeDependencies -Repository "LocalRepo1"
Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
1.0        Script-WithDependencies1            Script     LocalRepo1           Description for the Script-WithDependencies1 script
2.0        RequiredModule3                     Script     LocalRepo1           RequiredModule3 module
2.5        Required-Script1                    Script     LocalRepo1           Description for the Required-Script1 script
2.5        Required-Script2                    Script     LocalRepo1           Description for the Required-Script2 script
此命令查找脚本及其依赖项。
示例 8:查找具有指定标记的脚本
Find-Script -Tag "Tag1" -Repository "LocalRepo1"
Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
1.0        Fabrikam-ClientScript               Script     LocalRepo1           Description for the Fabrikam-ClientScript script
此命令查找在 LocalRepo1 存储库中具有标记 Tag1 的脚本
示例 9:查找具有指定命令名称的脚本
Find-Script -Command Test-FunctionFromScript_Required-Script3 -Repository "LocalRepo1"
Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
2.5        Required-Script3                    Script     LocalRepo1           Description for the Required-Script3 script
此命令查找包含指定命令名称的脚本。
示例 10:使用工作流查找脚本
Find-Script -Includes "Workflow" -Repository "LocalRepo1"
Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
2.5        Fabrikam-ClientScript               Script     LocalRepo1           Description for the Fabrikam-ClientScript script
1.0        Fabrikam-Script                     Script     LocalRepo1           Description for the Fabrikam-Script script
此命令在 LocalRepo1 存储库中查找工作流脚本。
示例 11:使用通配符查找脚本
Find-Script -Name "Required-Script*" -Repository "LocalRepo1"
Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
2.5        Required-Script1                    Script     local1               Description for the Required-Script1 script
2.5        Required-Script2                    Script     local1               Description for the Required-Script2 script
2.5        Required-Script3                    Script     local1               Description for the Required-Script3 script
此命令使用通配符 (*) 查找以 Required-Script 开头的脚本。
参数
-AllowPrerelease 
		包括在标记为预发行版的结果脚本中。
参数属性
| 类型: | SwitchParameter | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
-AllVersions 
		指示此作查找所有脚本版本。
参数属性
| 类型: | SwitchParameter | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
-Command
指定要在脚本中查找的命令数组。 命令可以是函数或工作流。
参数属性
| 类型: | String[] | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
-Credential
该 Find-Script cmdlet 在已注册的存储库中查找指定的脚本。
参数属性
| 类型: | PSCredential | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | True | 
| 来自剩余参数的值: | False | 
-Filter
根据 PackageManagement 提供程序特定的搜索语法查找脚本。
参数属性
| 类型: | String | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
-IncludeDependencies 
		指示此作获取依赖于 Name 参数中指定的脚本的所有脚本。
参数属性
| 类型: | SwitchParameter | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
-Includes
指定要获取的脚本类型。 此参数的可接受值为:
- Function
- Workflow
参数属性
| 类型: | String[] | 
| 默认值: | None | 
| 接受的值: | Function, Workflow | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
-MaximumVersion 
		指定要查找的脚本的最大版本或最新版本。 MaximumVersion 和 RequiredVersion 参数互斥;不能在同一命令中使用这两个参数。
参数属性
| 类型: | String | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | True | 
| 来自剩余参数的值: | False | 
-MinimumVersion 
		指定要查找的脚本的最低版本。 MinimumVersion 和 RequiredVersion 参数互斥;不能在同一命令中使用这两个参数。
参数属性
| 类型: | String | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | True | 
| 来自剩余参数的值: | False | 
-Name
指定要查找的脚本名称数组。
参数属性
| 类型: | String[] | 
| 默认值: | None | 
| 支持通配符: | True | 
| 不显示: | False | 
参数集
(All)
| Position: | 0 | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | True | 
| 来自剩余参数的值: | False | 
-Proxy
指定请求的代理服务器,而不是直接连接到 Internet 资源。
参数属性
| 类型: | Uri | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | True | 
| 来自剩余参数的值: | False | 
-ProxyCredential 
		指定有权使用 Proxy 参数指定的代理服务器的用户帐户。
参数属性
| 类型: | PSCredential | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | True | 
| 来自剩余参数的值: | False | 
-Repository
指定通过运行 Register-PSRepository注册的存储库的友好名称。
参数属性
| 类型: | String[] | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
-RequiredVersion 
		指定要查找的脚本的确切版本号。
参数属性
| 类型: | String | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | True | 
| 来自剩余参数的值: | False | 
-Tag
指定一个标签数组。
参数属性
| 类型: | String[] | 
| 默认值: | None | 
| 支持通配符: | False | 
| 不显示: | False | 
参数集
(All)
| Position: | Named | 
| 必需: | False | 
| 来自管道的值: | False | 
| 来自管道的值(按属性名称): | False | 
| 来自剩余参数的值: | False | 
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输入
String
String
Uri
PSCredential
输出
PSRepositoryItemInfo
备注
重要
截至 2020 年 4 月,PowerShell 库不再支持传输层安全性(TLS)版本 1.0 和 1.1。 如果未使用 TLS 1.2 或更高版本,则尝试访问 PowerShell 库时会收到错误。 使用以下命令确保使用的是 TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
有关详细信息,请参阅 PowerShell 博客中的 公告。