Set-PackageSource
取代指定封裝提供者的套件來源。
Syntax
Set-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[[-Name] <String>]
[-Location <String>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ProviderName <String>]
[<CommonParameters>]
Set-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Credential <PSCredential>]
[-NewLocation <String>]
[-NewName <String>]
[-Trusted]
-InputObject <PackageSource>
[-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>]
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>]
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>]
Description
會 Set-PackageSource
取代指定封裝提供者的封裝來源。 套件來源一律受套件提供者管理。
範例
範例 1:變更套件來源
此命令會變更封裝來源的現有名稱。 來源會設定為 [信任],這可排除在安裝套件時驗證來源的提示。
PS C:\> Set-PackageSource -Name MyNuget -NewName NewNuGet -Trusted -ProviderName NuGet
參數
-ConfigFile
指定組態檔。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
在執行 Cmdlet 前提示您確認。
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
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 |
-Force
強制執行命令而不要求使用者確認。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ForceBootstrap
Set-PackageSource
表示強制PackageManagement自動安裝套件提供者。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InputObject
指定封裝來源識別碼物件,代表您想要變更的封裝。 套件來源識別碼是 Cmdlet 結果的 Get-PackageSource
一部分。
Type: | Microsoft.PackageManagement.Packaging.PackageSource |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Location
指定目前的套件來源位置。 此值可以是 URI、檔案路徑,或套件提供者所支援的任何其他目的地格式。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
指定封裝來源的名稱。
Type: | String |
Aliases: | SourceName |
Position: | 0 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-NewLocation
指定封裝來源的新位置。 此值可以是 URI、檔案路徑,或套件提供者所支援的任何其他目的地格式。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-NewName
指定您指派給封裝來源的新名稱。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PackageManagementProvider
指定套件管理提供者。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ProviderName
指定提供者名稱。
Type: | String |
Aliases: | Provider |
Accepted values: | Bootstrap, NuGet, PowerShellGet |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Proxy
指定要求的 Proxy 伺服器,而不是直接連線到網際網路資源。
Type: | Uri |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ProxyCredential
指定具有使用 Proxy 參數所指定 Proxy 伺服器之權限的使用者帳戶。
Type: | PSCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PublishLocation
指定發行位置。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ScriptPublishLocation
指定腳本發佈位置。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ScriptSourceLocation
指定腳本來源位置。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SkipValidate
略過驗證封裝來源認證的參數。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Trusted
表示來源是受信任的套件提供者。 信任的來源不會提示驗證以安裝套件。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
顯示執行 Cmdlet 後會發生的情況。 Cmdlet 並不會執行。
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸入
None
您無法使用管線將物件傳送至此 Cmdlet。
輸出
None
此 Cmdlet 不會傳回任何輸出。
備註
重要
從 2020 年 4 月起,PowerShell 資源庫已不再支援傳輸層安全性 (TLS) 1.0 和 1.1 版。 如果您不是使用 TLS 1.2 或更高版本,您在嘗試存取 PowerShell 資源庫時將會收到錯誤。 使用下列命令來確保您使用的是 TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
如需詳細資訊,請參閱 PowerShell 部落格中的公告 \(英文\)。