Set-PSResourceRepository

登録済みリポジトリの情報を設定します。

構文

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>]

説明

コマンドレットは Set-PSResourceRepository 、登録済みリポジトリの情報を設定します。

例 1

この例では、PoshTestGallery リポジトリの Uri が登録されています。 コマンドレットは Set-PSResourceRepositoryUri をローカル パスに変更するために使用されます。 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

次の使用例は、リポジトリの Priority 値と Trusted 値を変更します。

注意

既定の 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 を使用します
  • local - ファイル システム ベースのリポジトリに使用します
  • nugetServer - これは NuGet.Server ベースのリポジトリに使用します

コマンドレットは Register-PSResourceRepository API バージョンを自動的に検出する必要があります。 このパラメーターを使用すると、リポジトリを登録した後で API のバージョンを変更できます。

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

コマンドレットの実行前に確認を求めるメッセージが表示されます。

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CredentialInfo

コンテナーの名前と、Microsoft.PowerShell.SecretManagement ストアに格納されているシークレットを含む PSCredentialInfo オブジェクト。

Type:Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

変更するリポジトリの名前を指定します。

注意

既定の PSGallery リポジトリの Uri 値は変更できません。

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

指定すると、正常に登録されたリポジトリとその情報が表示されます。

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Priority

リポジトリの優先度のランク付けを指定します。 有効な優先度の値の範囲は 0 から 100 です。 値が小さいと、優先順位のランク付けが高くなります。 既定値は 50 です。

リポジトリは優先度順、名前順に並べ替えられます。 複数のリポジトリ間でリソースを検索する場合、 PSResourceGet コマンドレットは、この並べ替え順序を使用してリポジトリを検索し、最初に見つかった一致を返します。

Type:Int32
Position:Named
Default value:50
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Repository

リポジトリ情報を含むハッシュテーブルの配列を指定します。 複数のリポジトリを一度に登録するには、このパラメーターを使用します。 各ハッシュテーブルには、 NameParameterSet のパラメーターに関連付けられているキーのみを含めることができます。

Type:Hashtable[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Trusted

リポジトリを信頼するかどうかを指定します。

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Uri

登録するリポジトリの場所を指定します。 値には、次のいずれかの URI スキーマを使用する必要があります。

  • https://
  • http://
  • ftp://
  • file://
Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

コマンドレットの実行時に発生する内容を示します。 コマンドレットは実行されません。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

入力

String

出力

Microsoft.PowerShell.PSResourceGet.UtilClasses.PSRepositoryInfo

既定では、コマンドレットは出力を生成しません。 PassThru パラメーターを使用すると、コマンドレットは PSRepositoryInfo オブジェクトを返します。