Import-PSGetRepository
尋找向 PowerShellGet 註冊的存放庫,併為 PSResourceGet 註冊存放庫。
語法
Default (預設值)
Import-PSGetRepository
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
此 Cmdlet 會尋找向 PowerShellGet v2 註冊的 NuGet 存放庫,併為 PSResourceGet 註冊它們。 PowerShellGet v2 具有提供者模型,可讓您註冊使用不同的提供者通訊協定的存放庫。 PSResourceGet 僅支援 NuGet 存放庫,因此此 Cmdlet 只會匯入 NuGet 存放庫。
根據預設,PSGallery 存放庫會註冊。 此 Cmdlet 不會從 PowerShellGet v2 匯入 PSGallery 存放庫。 如果您需要重新註冊 PSGallery 存放庫,請使用 Register-PSResourceRepository Cmdlet 搭配 PSGallery 參數。
範例
範例 1 - 顯示向 PowerShellGet v2 註冊的 NuGet 存放庫
此範例會使用 Verbose 和 WhatIf 參數來顯示向 PowerShell v2 註冊的 NuGet 存放庫。
Import-PSGetRepository -Verbose -WhatIf
VERBOSE: Found 3 registered PowerShellGet repositories.
VERBOSE: Selected 2 NuGet repositories.
What if: Registering LocalGallery at E:\LocalGallery\ -Trusted:$True -Force:$False.
What if: Registering PrivateRepo at https://PrivateRepo:44370/nuget -Trusted:$True -Force:$False.
Cmdlet 找到三個向 PowerShellGet v2 註冊的存放庫,但只會匯入其中兩個存放庫。 在此情況下,第三個存放庫是 PSGallery 存放庫的預設。
範例 2 - 註冊向 PowerShellGet v2 註冊的 NuGet 存放庫
Import-PSGetRepository
Name Uri Trusted Priority
---- --- ------- --------
LocalGallery file:///E:/LocalGallery/ True 50
PrivateRepo https://PrivateRepo:44370/nuget True 50
範例 3 - 覆寫現有的存放庫
根據預設,Cmdlet 不會匯入名稱與已註冊 PSResourceGet 存放庫相同的 PowerShellGet v2 存放庫。 使用 Force 參數來覆寫現有的存放庫。
Import-PSGetRepository
WARNING: Adding to repository store failed: The PSResource Repository 'LocalGallery' already exists.
WARNING: Use the -Force switch to overwrite existing repositories.
WARNING: Adding to repository store failed: The PSResource Repository 'PrivateRepo' already exists.
WARNING: Use the -Force switch to overwrite existing repositories.
Import-PSGetRepository -Force
Name Uri Trusted Priority
---- --- ------- --------
LocalGallery file:///E:/LocalGallery/ True 50
PrivateRepo https://PrivateRepo:44370/nuget True 50
參數
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | cf |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Force
使用 Force 參數來覆寫現有的存放庫。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 該 Cmdlet 未被執行。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | 無線 |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸出
Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo
Cmdlet 會針對向 PowerShellGet v2 註冊的每個 NuGet 存放庫傳回 PSRepositoryInfo 物件。