共用方式為


Set-PSRepository

設定已註冊存放庫的值。

語法

Set-PSRepository
   [-Name] <String>
   [[-SourceLocation] <Uri>]
   [-PublishLocation <Uri>]
   [-ScriptSourceLocation <Uri>]
   [-ScriptPublishLocation <Uri>]
   [-Credential <PSCredential>]
   [-InstallationPolicy <String>]
   [-Proxy <Uri>]
   [-ProxyCredential <PSCredential>]
   [-PackageManagementProvider <String>]
   [<CommonParameters>]

Description

Cmdlet 會 Set-PSRepository 設定已註冊模組存放庫的值。 目前用戶的設定是持續性的,並套用至為該使用者安裝的所有PowerShell版本。

這是 Microsoft.PowerShell.PSResourceGet 中 Cmdlet 的 Proxy CmdletSet-PSResourceRepository。 如需詳細資訊,請參閱 Set-PSResourceRepository

範例

範例 1:設定存放庫的安裝原則

Set-PSRepository -Name "myInternalSource" -InstallationPolicy Trusted

此命令會將 myInternalSource 存放庫的安裝原則設定為 Trusted,如此一來,您就不會在從該來源安裝模組之前收到提示。

範例 2:設定存放庫的來源和發佈位置

Set-PSRepository -Name "myInternalSource" -SourceLocation 'https://someNuGetUrl.com/api/v2' -PublishLocation 'https://someNuGetUrl.com/api/v2/packages'

此命令會將 myInternalSource 的來源位置和發佈位置設定為指定的 URI。

參數

-Credential

Proxy Cmdlet 會忽略此參數,因為它不受 支援 Set-PSResourceRepository

類型:PSCredential
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-InstallationPolicy

指定安裝原則。 有效值為: TrustedUntrusted

Proxy Cmdlet 會將此參數的值轉換為 的 Set-PSResourceRepositoryTrusted 參數。

類型:String
接受的值:Trusted, Untrusted
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Name

指定存放庫的名稱。

類型:String
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-PackageManagementProvider

Proxy Cmdlet 會忽略此參數,因為它不受 支援 Set-PSResourceRepository

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Proxy

Proxy Cmdlet 會忽略此參數,因為它不受 支援 Set-PSResourceRepository

類型:Uri
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-ProxyCredential

Proxy Cmdlet 會忽略此參數,因為它不受 支援 Set-PSResourceRepository

類型:PSCredential
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-PublishLocation

Proxy Cmdlet 會忽略此參數,因為它不受 支援 Set-PSResourceRepository

類型:Uri
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ScriptPublishLocation

Proxy Cmdlet 會忽略此參數,因為它不受 支援 Set-PSResourceRepository

類型:Uri
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ScriptSourceLocation

Proxy Cmdlet 會忽略此參數,因為它不受 支援 Set-PSResourceRepository

類型:Uri
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceLocation

指定從這個存放庫探索及安裝模組的 URI。 例如,針對 NuGet 型存放庫,來源位置類似於 https://someNuGetUrl.com/api/v2

Proxy Cmdlet 會將此參數對應至 的 Set-PSResourceRepositoryUri 參數。

類型:Uri
Position:1
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

String

PSCredential

Uri

輸出

Object

備註

PowerShell 資源庫不再支援傳輸層安全性 (TLS) 1.0 和 1.1 版。 您必須使用 TLS 1.2 或更高版本。 使用下列命令以確保您使用 TLS 1.2:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12