Find-Package
查找可用包源中的软件包。
语法
Find-Package
[-IncludeDependencies]
[-AllVersions]
[-Source <String[]>]
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[[-Name] <String[]>]
[-RequiredVersion <String>]
[-MinimumVersion <String>]
[-MaximumVersion <String>]
[-Force]
[-ForceBootstrap]
[-ProviderName <String[]>]
[-ConfigFile <String>]
[-SkipValidate]
[-Headers <String[]>]
[-FilterOnTag <String[]>]
[-Contains <String>]
[-AllowPrereleaseVersions]
[<CommonParameters>]
Find-Package
[-IncludeDependencies]
[-AllVersions]
[-Source <String[]>]
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[[-Name] <String[]>]
[-RequiredVersion <String>]
[-MinimumVersion <String>]
[-MaximumVersion <String>]
[-Force]
[-ForceBootstrap]
[-ProviderName <String[]>]
[-AllowPrereleaseVersions]
[-PackageManagementProvider <String>]
[-PublishLocation <String>]
[-ScriptSourceLocation <String>]
[-ScriptPublishLocation <String>]
[-Type <String>]
[-Filter <String>]
[-Tag <String[]>]
[-Includes <String[]>]
[-DscResource <String[]>]
[-RoleCapability <String[]>]
[-Command <String[]>]
[-AcceptLicense]
[<CommonParameters>]
说明
Find-Package
查找包源中可用的软件包。
Get-PackageProvider
并 Get-PackageSource
显示有关提供商的详细信息。
重要
PackageManagement 模块中包含的命令不同于 Visual Studio 的包管理器控制台中 NuGet 模块提供的命令。 每个模块都有在其他模块中不可用的命令。 具有相同名称的命令在其特定参数中有所不同。 有关详细信息,请参阅 Visual Studio 的包管理器控制台的 PowerShell 参考 文档。
示例
示例 1:查找包提供程序中的所有可用包
此命令在已注册的库中查找所有可用的 PowerShell 模块包。 用于 Get-PackageProvider
获取提供程序名称。
Find-Package -ProviderName NuGet
Name Version Source Summary
---- ------- ------ -------
NUnit 3.11.0 MyNuGet NUnit is a unit-testing framework for all .NET langua...
Newtonsoft.Json 12.0.1 MyNuGet Json.NET is a popular high-performance JSON framework...
EntityFramework 6.2.0 MyNuGet Entity Framework is Microsoft's recommended data acce...
MySql.Data 8.0.15 MyNuGet MySql.Data.MySqlClient .Net Core Class Library
bootstrap 4.3.1 MyNuGet Bootstrap framework in CSS. Includes fonts and JavaSc...
NuGet.Core 2.14.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
Find-Package
使用 Provider 参数指定提供程序 NuGet。
示例 2:从包源查找包
此命令从指定的包源中查找包的最新版本。 如果未提供包源,请 Find-Package
搜索每个已安装的包提供程序及其包源。 用于 Get-PackageSource
获取源名称。
Find-Package -Name NuGet.Core -Source MyNuGet
Name Version Source Summary
---- ------- ------ -------
NuGet.Core 2.14.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
Find-Package
使用 Name 参数指定包名称 NuGet.Core。
Source 参数指定在 MyNuGet 中搜索包。
示例 3:查找包的所有版本
此命令查找指定提供程序中的所有可用包版本。
Find-Package -Name NuGet.Core -Source MyNuGet -AllVersions
Name Version Source Summary
---- ------- ------ -------
NuGet.Core 2.14.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
NuGet.Core 2.14.0-rtm-832 MyNuGet NuGet.Core is the core framework assembly for NuGet...
NuGet.Core 2.13.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
...
NuGet.Core 1.1.229.159 MyNuGet NuGet.Core is the core framework assembly for NuGet...
Nuget.Core 1.0.1120.104 MyNuGet NuGet.Core is the core framework assembly for NuGet...
Find-Package
使用 Name 参数指定包 NuGet.Core。
ProviderName 参数指定在 MyNuGet 中搜索包。
AllVersions 指定返回所有可用版本。
示例 4:查找具有特定名称和版本的包
此命令从指定的提供程序查找特定包版本。
Find-Package -Name NuGet.Core -ProviderName NuGet -RequiredVersion 2.9.0
Name Version Source Summary
---- ------- ------ -------
NuGet.Core 2.9.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
Find-Package
使用 Name 参数指定包名称 NuGet.Core。
ProviderName 参数指定在 NuGet 中搜索包。
RequiredVersion 指定仅返回版本 2.9.0 。
示例 5:在一系列版本中查找包
此命令查找指定包的一系列版本。
Find-Package -Name NuGet.Core -ProviderName NuGet -MinimumVersion 2.7.0 -MaximumVersion 2.9.0 -AllVersions
Name Version Source Summary
---- ------- ------ -------
NuGet.Core 2.9.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
NuGet.Core 2.8.6 MyNuGet NuGet.Core is the core framework assembly for NuGet...
NuGet.Core 2.8.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
NuGet.Core 2.7.0 MyNuGet NuGet.Core is the core framework assembly for NuGet...
Find-Package
使用 Name 参数指定包名称 NuGet.Core。
ProviderName 参数指定在 NuGet 中搜索包。
MinimumVersion 指定最低版本 2.7.0。
MaximumVersion 指定最高版本 2.9.0。
AllVersions 确定按最小值和最大值指定的范围返回。
示例 6:从文件系统查找包
此命令查找本地计算机上存储的文件扩展名 .nupkg
的包。
这些文件是从库(如 NuGet)下载的包。
PS> Find-Package -Source C:\LocalPkg
Name Version Source Summary
---- ------- ------ -------
Microsoft.Web.Xdt 3.0.0 C:\LocalPkg\ Microsoft Xml Document Transformation (XDT)...
NuGet.Core 2.14.0 C:\LocalPkg\ NuGet.Core is the core framework assembly...
参数
-AcceptLicense
如果包需要许可协议,则自动接受许可协议。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-AllowPrereleaseVersions
在结果中包含标记为预发行版的包。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-AllVersions
指示 Find-Package
返回包的所有可用版本。 默认情况下, Find-Package
仅返回最新可用版本。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Command
指定按 Find-Package
. 搜索的命令数组。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ConfigFile
指定配置文件。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Contains
Find-Package
如果对象的属性值中的任何项与指定值完全匹配,则获取对象。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Credential
指定有权搜索包的用户帐户。
类型: | PSCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DscResource
指定此 cmdlet 搜索的 Desired State Configuration (DSC) 资源的数组。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Filter
指定要在 Name 和 Description 属性中搜索的术语。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-FilterOnTag
指定筛选结果的标记。 不包括不包含指定标记的结果。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Force
强制命令运行而不要求用户确认。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ForceBootstrap
指示 Find-Package
强制 PackageManagement 自动安装包提供程序。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Headers
指定包的标头。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-IncludeDependencies
指示此 cmdlet 在结果中包含包依赖项。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Includes
指定是否 Find-Package
应查找类别中的所有包。
接受的值如下所示:
- Cmdlet
- DscResource
- 功能
- RoleCapability
- 工作流程
类型: | String[] |
接受的值: | Cmdlet, DscResource, Function, RoleCapability, Workflow |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-MaximumVersion
指定要查找的最大包版本。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-MinimumVersion
指定要查找的最低包版本。 如果较高版本可用,则返回该版本。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Name
指定一个或多个包名称,或包含通配符的包名称。 用逗号分隔多个包名称。
类型: | String[] |
Position: | 0 |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | True |
-PackageManagementProvider
指定包管理提供程序的名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ProviderName
指定一个或多个包提供程序名称。 用逗号分隔多个包提供程序名称。
用于 Get-PackageProvider
获取可用包提供程序的列表。
类型: | String[] |
别名: | Provider |
接受的值: | Bootstrap, NuGet, PowerShellGet |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Proxy
为请求指定代理服务器,而不是直接连接到 Internet 资源。
类型: | Uri |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ProxyCredential
指定有权使用 Proxy 参数指定的代理服务器的用户帐户。
类型: | PSCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-PublishLocation
指定用于发布包的位置。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RequiredVersion
指定要查找的确切包版本。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RoleCapability
指定角色功能的数组。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ScriptPublishLocation
指定包的脚本发布位置。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ScriptSourceLocation
指定脚本源位置。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-SkipValidate
跳过包凭据验证的开关。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Source
指定一个或多个包源。 用于 Get-PackageSource
获取可用包源的列表。 文件系统目录可用作下载包的源。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Tag
指定要在包元数据中搜索的一个或多个字符串。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Type
指定是搜索包含模块、脚本的包,还是搜索包。
类型: | String |
接受的值: | Module, Script, All |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
None
不能用管道将对象传送到此 cmdlet。
输出
SoftwareIdentify[]
此 cmdlet 返回 SoftwareIdentity 对象。
备注
重要
截至 2020 年 4 月,PowerShell 库不再支持传输层安全性(TLS)版本 1.0 和 1.1。 如果未使用 TLS 1.2 或更高版本,则尝试访问 PowerShell 库时会收到错误。 使用以下命令确保使用的是 TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
有关详细信息,请参阅 PowerShell 博客中的 公告。