Get-PackageSource
Gets a list of package sources that are registered for a package provider.
语法
NuGet
Get-PackageSource
[[-Name] <String>]
[-Location <String>]
[-Force]
[-ForceBootstrap]
[-ProviderName <String[]>]
[-ConfigFile <String>]
[-SkipValidate]
[<CommonParameters>]
PowerShellGet
Get-PackageSource
[[-Name] <String>]
[-Location <String>]
[-Force]
[-ForceBootstrap]
[-ProviderName <String[]>]
[-PackageManagementProvider <String>]
[-PublishLocation <String>]
[-ScriptSourceLocation <String>]
[-ScriptPublishLocation <String>]
[<CommonParameters>]
说明
The Get-PackageSource
cmdlet gets a list of package sources that are registered with
PackageManagement on the local computer. If you specify a package provider, Get-PackageSource
gets only those sources that are associated with the specified provider. Otherwise, the command
returns all package sources that are registered with PackageManagement.
示例
Example 1: Get all package sources
The Get-PackageSource
cmdlet gets all package sources that are registered with
PackageManagement on the local computer.
Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
LocalPackages NuGet False C:\LocalPkg\
MyNuget NuGet False https://www.nuget.org/api/v2
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
Example 2: Get all package sources for a specific provider
This command gets package sources that are registered for a specific provider.
Get-PackageSource -ProviderName NuGet
Name ProviderName IsTrusted Location
---- ------------ --------- --------
LocalPackages NuGet False C:\LocalPkg\
MyNuget NuGet False https://www.nuget.org/api/v2
Get-PackageSource
uses the ProviderName parameter to get package sources that are registered
for the NuGet provider.
Example 3: Get sources from a package provider
This command uses a package provider to get package sources.
Get-PackageProvider -Name NuGet | Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
LocalPackages NuGet False C:\LocalPkg\
MyNuget NuGet False https://www.nuget.org/api/v2
Get-PackageProvider
uses the Name parameter specify the provider name, NuGet. The object
is sent down the pipeline to Get-PackageSource
.
参数
-ConfigFile
Specifies a configuration file.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
NuGet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Force
Forces the command to run without asking for user confirmation.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-ForceBootstrap
Indicates that this cmdlet forces PackageManagement to automatically install a package provider.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Location
Specifies the location of a package management source or repository.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Name
Specifies the name of a package management source.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | 0 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-PackageManagementProvider
Specifies a package management provider.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
PowerShellGet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-ProviderName
Specifies one or more package provider names. Separate multiple package provider names with commas.
Use Get-PackageProvider
to get a list of available package providers.
参数属性
类型: | String[] |
默认值: | None |
接受的值: | Bootstrap, NuGet, PowerShellGet |
支持通配符: | False |
不显示: | False |
别名: | Provider |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-PublishLocation
Specifies the publish location for the package source.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
PowerShellGet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-ScriptPublishLocation
Specifies the script publish location.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
PowerShellGet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-ScriptSourceLocation
Specifies the script source location.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
PowerShellGet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-SkipValidate
Switch that skips validating the credentials of a package source.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
NuGet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
输出
Microsoft.PackageManagement.Packaging.PackageSource
This cmdlet returns a PackageSource object for each registered package source that fulfills the criteria set by the parameters. By default, it returns every registered package source.
备注
Important
As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
For more information, see the announcement in the PowerShell blog.