Set-PSResourceRepository
Mengatur informasi untuk repositori terdaftar.
Sintaks
Set-PSResourceRepository
[-Name] <String>
[-Uri <String>]
[-Trusted]
[-Priority <Int32>]
[-ApiVersion <APIVersion>]
[-CredentialInfo <PSCredentialInfo>]
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-PSResourceRepository
-Repository <Hashtable[]>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Deskripsi
Set-PSResourceRepository
Cmdlet menetapkan informasi untuk repositori terdaftar.
Contoh
Contoh 1
Dalam contoh ini, Uri untuk repositori PoshTestGallery telah didaftarkan. Set-PSResourceRepository
Cmdlet digunakan untuk mengubah Uri ke jalur lokal. Parameter PassThru memungkinkan Anda melihat repositori yang diubah.
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
Contoh 2
Contoh ini mengubah nilai Prioritas dan Tepercaya dari repositori.
Catatan
Nilai Uri dari repositori PSGallery default tidak dapat diubah.
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
Contoh: 3
Contoh ini menggunakan parameter Repositori untuk mengubah nilai untuk beberapa repositori. Parameter mengambil array hashtable. Setiap hashtable berisi informasi repositori yang sedang diperbarui.
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
Contoh 4
Contoh ini memperbarui repositori dengan informasi kredensial yang akan diambil dari vault Microsoft.PowerShell.SecretManagement yang terdaftar. Anda harus menginstal modul Microsoft.PowerShell.SecretManagement dan memiliki vault terdaftar yang berisi rahasia yang disimpan. Format rahasia harus sesuai dengan persyaratan repositori.
$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 :
Parameter
-ApiVersion
Menentukan versi API yang digunakan oleh repositori. Nilai yang valid adalah:
v2
- menggunakan API NuGet V2v3
- menggunakan API NuGet V3local
- gunakan ini untuk repositori berbasis sistem filenugetServer
- gunakan ini untuk repositori berbasis NuGet.Server
Cmdlet Register-PSResourceRepository
harus secara otomatis mendeteksi versi API. Parameter ini memungkinkan Anda mengubah versi API setelah Anda mendaftarkan repositori.
Type: | Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo+APIVersion |
Accepted values: | unknown, v2, v3, local, nugetServer |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Meminta Anda mengonfirmasi sebelum menjalankan cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-CredentialInfo
Objek PSCredentialInfo yang menyertakan nama vault dan rahasia yang disimpan di penyimpanan Microsoft.PowerShell.SecretManagement .
Type: | Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
Menentukan nama repositori yang akan dimodifikasi.
Catatan
Nilai Uri dari repositori PSGallery default tidak dapat diubah.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PassThru
Ketika ditentukan, menampilkan repositori yang berhasil didaftarkan dan informasinya.
Type: | SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Priority
Menentukan peringkat prioritas repositori. Nilai prioritas yang valid berkisar antara 0 hingga 100. Nilai yang lebih rendah memiliki peringkat prioritas yang lebih tinggi. Nilai defaultnya adalah 50
.
Repositori diurutkan berdasarkan prioritas, lalu berdasarkan nama. Saat mencari sumber daya di beberapa repositori, cmdlet PSResourceGet mencari repositori menggunakan urutan sortir ini dan mengembalikan kecocokan pertama yang ditemukan.
Type: | Int32 |
Position: | Named |
Default value: | 50 |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Repository
Menentukan array hashtable yang berisi informasi repositori. Gunakan parameter ini untuk mendaftarkan beberapa repositori sekaligus. Setiap hashtable hanya dapat memiliki kunci yang terkait dengan parameter untuk NameParameterSet.
Type: | Hashtable[] |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Trusted
Menentukan apakah repositori harus dipercaya.
Type: | SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Uri
Menentukan lokasi repositori yang akan didaftarkan. Nilai harus menggunakan salah satu skema URI berikut:
https://
http://
ftp://
file://
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Menunjukkan yang akan terjadi jika cmdlet dijalankan. Cmdlet tidak dijalankan.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Input
Output
Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo
Secara default, cmdlet tidak menghasilkan output. Saat Anda menggunakan parameter PassThru , cmdlet mengembalikan objek PSRepositoryInfo .
Link Terkait
PSResourceGet
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk