Register-PackageSource
加入指定套件提供者的套件來源。
Syntax
Register-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[[-Name] <String>]
[[-Location] <String>]
[-Credential <PSCredential>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ProviderName <String>]
[<CommonParameters>]
Register-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[[-Name] <String>]
[[-Location] <String>]
[-Credential <PSCredential>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ConfigFile <String>]
[-SkipValidate]
[<CommonParameters>]
Register-PackageSource
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[[-Name] <String>]
[[-Location] <String>]
[-Credential <PSCredential>]
[-Trusted]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-PackageManagementProvider <String>]
[-PublishLocation <String>]
[-ScriptSourceLocation <String>]
[-ScriptPublishLocation <String>]
[<CommonParameters>]
Description
Cmdlet Register-PackageSource
會為指定的套件提供者新增套件來源。 套件來源一律受套件提供者管理。 如果套件提供者不能新增或取代套件來源,提供者會產生錯誤訊息。
範例
範例 1:註冊 NuGet 提供者的套件來源
此命令會註冊套件來源,這是 NuGet 提供者的 Web 型位置。 根據預設,來源不受信任。 系統會提示您在安裝套件之前確認來源受信任。 若要覆寫預設值,請使用 -Trusted
參數。
Register-PackageSource -Name MyNuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet
Name ProviderName IsTrusted Location
---- ------------ --------- --------
MyNuGet NuGet False https://www.nuget.org/api/v2
參數
-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
指示此 Cmdlet 會自動安裝套件提供者。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Location
指定套件來源位置。
Type: | String |
Position: | 1 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
指定要註冊的套件來源名稱。
Type: | String |
Position: | 0 |
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 |
備註
重要
從 2020 年 4 月起,PowerShell 資源庫已不再支援傳輸層安全性 (TLS) 1.0 和 1.1 版。 如果您不是使用 TLS 1.2 或更高版本,您在嘗試存取 PowerShell 資源庫時將會收到錯誤。 使用下列命令來確保您使用的是 TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
如需詳細資訊,請參閱 PowerShell 部落格中的公告 \(英文\)。