Set-PackageSource
Replaces a package source for a specified package provider.
语法
SourceBySearch (默认值)
Set-PackageSource
[[-Name] <String>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-Location <String>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ProviderName <String>]
[<CommonParameters>]
Set-PackageSource
-InputObject <PackageSource>
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ConfigFile <String>]
[-SkipValidate]
[<CommonParameters>]
NuGet:SourceBySearch
Set-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ConfigFile <String>]
[-SkipValidate]
[<CommonParameters>]
Set-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-PackageManagementProvider <String>]
[-PublishLocation <String>]
[-ScriptSourceLocation <String>]
[-ScriptPublishLocation <String>]
[<CommonParameters>]
PowerShellGet:SourceBySearch
Set-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-PackageManagementProvider <String>]
[-PublishLocation <String>]
[-ScriptSourceLocation <String>]
[-ScriptPublishLocation <String>]
[<CommonParameters>]
说明
The Set-PackageSource
replaces a package source for a specified package provider. Package sources
are always managed by a package provider.
示例
Example 1: Change a package source
This command changes the existing name of a package source. The source is set to Trusted , which
eliminates prompts to verify the source when packages are installed.
PS C:\> Set-PackageSource -Name MyNuget -NewName NewNuGet -Trusted -ProviderName NuGet
参数
-ConfigFile
Specifies a configuration file.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
NuGet:SourceByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Confirm
Prompts you for confirmation before running the cmdlet.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Credential
Specifies a user account that has permission to install package providers.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Force
Forces the command to run without asking for user confirmation.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ForceBootstrap
Indicates that Set-PackageSource
forces PackageManagement to automatically install the package
provider.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
Specifies a package source ID object that represents the package that you want to change. Package
source IDs are part of the results of the Get-PackageSource
cmdlet.
类型: Microsoft.PackageManagement.Packaging.PackageSource
默认值: None
支持通配符: False
不显示: False
SourceByInputObject
Position: Named
必需: True
来自管道的值: True
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Location
Specifies the current package source location. The value can be a URI, a file path, or any other
destination format supported by the package provider.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Name
Specifies a package source's name.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
别名: SourceName
参数集
SourceBySearch
Position: 0
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-NewLocation
Specifies the new location for a package source. The value can be a URI, a file path, or any other
destination format supported by the package provider.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-NewName
Specifies the new name you assign to a package source.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-PackageManagementProvider
Specifies a package management provider.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:SourceByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ProviderName
Specifies a provider name.
参数属性
类型: String
默认值: None
接受的值: Bootstrap, NuGet, PowerShellGet
支持通配符: False
不显示: False
别名: Provider
参数集
SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-Proxy
Specifies a proxy server for the request, rather than connecting directly to the Internet resource.
参数属性
类型: Uri
默认值: None
支持通配符: False
不显示: False
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ProxyCredential
Specifies a user account that has permission to use the proxy server that is specified by the
Proxy parameter.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-PublishLocation
Specifies the publish location.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:SourceByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ScriptPublishLocation
Specifies the script publish location.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:SourceByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ScriptSourceLocation
Specifies the script source location.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:SourceByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-SkipValidate
Switch that skips validating the credentials of a package source.
参数属性
参数集
NuGet:SourceByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:SourceBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Trusted
Indicates that the source is a trusted package provider. Trusted sources don't prompt for
verification to install packages.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
参数属性
参数集
(All)
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 .
You can't pipe objects to this cmdlet.
输出
None
This cmdlet returns no output.
备注
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.