Set-PSResourceRepository
設定已註冊存放庫的資訊。
語法
NameParameterSet (預設值)
Set-PSResourceRepository
[-Name] <String>
[-Uri <String>]
[-Trusted]
[-Priority <Int32>]
[-ApiVersion <APIVersion>]
[-CredentialInfo <PSCredentialInfo>]
[-PassThru]
[-CredentialProvider <CredentialProvider>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
RepositoriesParameterSet
Set-PSResourceRepository
-Repository <Hashtable[]>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Set-PSResourceRepository Cmdlet 會設定已註冊存放庫的資訊。
範例
範例 1
在此範例中,PoshTestGallery 存放庫的 Uri 已註冊。
Set-PSResourceRepository Cmdlet 可用來將 Uri 變更為本機路徑。
PassThru 參數可讓您查看變更的存放庫。
Get-PSResourceRepository -Name "PoshTestGallery"
Name Uri Trusted Priority
---- --- ------- --------
PoshTestGallery https://www.poshtestgallery.com/api/v2 False 50
Set-PSResourceRepository -Name "PoshTestGallery" -Uri "c:/code/testdir" -PassThru
Name Uri Trusted Priority
---- --- ------- --------
PoshTestGallery file:///c:/code/testdir False 50
範例 2
此範例會變更存放庫 優先順序 和 信任 值。
備註
無法變更預設 PSGallery 存放庫 URI 值。
Get-PSResourceRepository -Name "PSGallery"
Name Uri Trusted Priority
---- --- ------- --------
PSGallery https://www.powershellgallery.com/api/v2 False 50
Set-PSResourceRepository -Name "PSGallery" -Priority 25 -Trusted -PassThru
Name Uri Trusted Priority
---- --- ------- --------
PSGallery https://www.powershellgallery.com/api/v2 True 25
範例 3
此範例會使用 Repository 參數來變更多個存放庫的值。 參數會採用哈希表的陣列。 每個哈希表都包含要更新之存放庫的資訊。
Get-PSResourceRepository
Name Uri Trusted Priority
---- --- ------- --------
PSGallery https://www.powershellgallery.com/api/v2 False 50
PoshTestGallery https://www.poshtestgallery.com/api/v2 False 50
$arrayOfHashtables = @{Name = "PSGallery"; Trusted = $True},
@{Name = "PoshTestGallery"; Uri = "c:/code/testdir"}
Set-PSResourceRepository -Repository $arrayOfHashtables -PassThru
Name Uri Trusted Priority
---- --- ------- --------
PSGallery https://www.powershellgallery.com/api/v2 True 50
PoshTestGallery file:///c:/code/testdir False 50
範例 4
此範例會更新存放庫,其中包含要從已註冊的 Microsoft.PowerShell.SecretManagement 保存庫擷取的認證資訊。 您必須安裝 Microsoft.PowerShell.SecretManagement 模組,並具有包含預存秘密的已註冊保存庫。 秘密的格式必須符合存放庫的需求。
$parameters = @{
Name = "PoshTestGallery"
Uri = "c:/code/testdir"
CredentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo]::new(
'SecretStore', 'TestSecret')
}
Set-PSResourceRepository @parameters -PassThru |
Select-Object * -ExpandProperty CredentialInfo
Name : PoshTestGallery
Uri : file:///c:/code/testdir
Trusted : False
Priority : 50
CredentialInfo : Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo
VaultName : SecretStore
SecretName : TestSecret
Credential :
參數
-ApiVersion
指定存放庫所使用的 API 版本。 有效值為:
-
v2- 使用 NuGet V2 API -
v3- 使用 NuGet V3 API -
ContainerRegistry- 用於 Azure Container Registry -
local- 將此專案用於文件系統型存放庫 -
nugetServer- 針對 NuGet.Server 型存放庫使用此專案
Register-PSResourceRepository Cmdlet 應該會自動偵測 API 版本。 此參數可讓您在註冊存放庫之後變更 API 版本。
參數屬性
| 類型: | Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo+APIVersion |
| 預設值: | None |
| 接受的值: | V2, V3, Local, NugetServer, ContainerRegistry |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | cf |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-CredentialInfo
PSCredentialInfo 物件,其中包含保存庫的名稱,以及儲存在 Microsoft.PowerShell.SecretManagement 存放區中的秘密。
參數屬性
| 類型: | Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-CredentialProvider
這是一個動態參數,用來指定儲存庫要使用的憑證提供者。 此參數僅在指定儲存庫為 Azure 工件資料源時可用。 有效值為:
-
None- 未定義憑證提供者 -
AzArtifacts- 使用 Azure Artifacts 憑證提供者
參數屬性
| 類型: | Microsoft.PowerShell.PSResourceGet.UtilClasses.CredentialProviderType |
| 預設值: | None |
| 接受的值: | None, AzArtifacts |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Name
指定要修改之存放庫的名稱。
備註
無法變更預設 PSGallery 存放庫 URI 值。
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameParameterSet
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-PassThru
指定時,會顯示成功註冊的存放庫及其資訊。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Priority
指定存放庫的優先順序排名。 有效的優先順序值範圍從 0 到 100。 較低的值具有較高的優先順序排名。 預設值是 50。
存放庫會依優先順序排序,然後依名稱排序。 在多個存放庫之間搜尋資源時,PSResourceGet Cmdlet 會使用此排序順序搜尋存放庫,並傳回找到的第一個相符專案。
參數屬性
| 類型: | Int32 |
| 預設值: | 50 |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Repository
指定包含存放庫資訊的哈希表數位。 使用此參數一次註冊多個存放庫。 每個哈希表只能有與 NameParameterSet參數相關聯的索引鍵。
參數屬性
| 類型: | |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
RepositoriesParameterSet
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Trusted
指定是否應該信任存放庫。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Uri
指定要註冊之存放庫的位置。 值必須使用下列其中一個 URI 架構:
https://http://ftp://file://
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
NameParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 該 Cmdlet 未被執行。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | 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。
輸入
String
輸出
Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo
根據預設,Cmdlet 不會產生任何輸出。 當您使用 PassThru 參數時,Cmdlet 會傳回 PSRepositoryInfo 物件。