Set-PSRepository
设置已注册存储库的值。
语法
Default (默认值)
Set-PSRepository
[-Name] <String>
[[-SourceLocation] <Uri>]
[-PublishLocation <Uri>]
[-ScriptSourceLocation <Uri>]
[-ScriptPublishLocation <Uri>]
[-Credential <PSCredential>]
[-InstallationPolicy <String>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-PackageManagementProvider <String>]
[<CommonParameters>]
说明
该 Set-PSRepository cmdlet 设置已注册模块存储库的值。 这些设置对于当前用户是永久性的,适用于为该用户安装的所有 PowerShell 版本。
这是 Set-PSResourceRepository 中 cmdlet 的代理 cmdlet。 有关详细信息,请参阅 Set-PSResourceRepository。
示例
示例 1:设置存储库的安装策略
Set-PSRepository -Name "myInternalSource" -InstallationPolicy Trusted
此命令将 myInternalSource 存储库的安装策略设置为 “受信任”,以便在从该源安装模块之前不会提示你。
示例 2:设置存储库的源和发布位置
Set-PSRepository -Name "myInternalSource" -SourceLocation 'https://someNuGetUrl.com/api/v2' -PublishLocation 'https://someNuGetUrl.com/api/v2/packages'
此命令将 myInternalSource 的源位置和发布位置设置为指定的 URI。
参数
-Credential
代理 cmdlet 忽略此参数,因为它不受支持 Set-PSResourceRepository。
参数属性
| 类型: | PSCredential |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-InstallationPolicy
指定安装策略。 有效值为: 受信任、 不受信任。
代理 cmdlet 将此参数的值转换为 受信任的 参数 Set-PSResourceRepository。
参数属性
| 类型: | String |
| 默认值: | None |
| 接受的值: | Trusted, Untrusted |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Name
指定存储库的名称。
参数属性
| 类型: | String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | 0 |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-PackageManagementProvider
代理 cmdlet 忽略此参数,因为它不受支持 Set-PSResourceRepository。
参数属性
| 类型: | String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Proxy
代理 cmdlet 忽略此参数,因为它不受支持 Set-PSResourceRepository。
参数属性
| 类型: | Uri |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-ProxyCredential
代理 cmdlet 忽略此参数,因为它不受支持 Set-PSResourceRepository。
参数属性
| 类型: | PSCredential |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-PublishLocation
代理 cmdlet 忽略此参数,因为它不受支持 Set-PSResourceRepository。
参数属性
| 类型: | Uri |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-ScriptPublishLocation
代理 cmdlet 忽略此参数,因为它不受支持 Set-PSResourceRepository。
参数属性
| 类型: | Uri |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-ScriptSourceLocation
代理 cmdlet 忽略此参数,因为它不受支持 Set-PSResourceRepository。
参数属性
| 类型: | Uri |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-SourceLocation
指定用于从此存储库中发现和安装模块的 URI。 例如,对于基于 NuGet 的存储库,源位置类似于 https://someNuGetUrl.com/api/v2。
代理 cmdlet 将此参数映射到 URI Set-PSResourceRepository
参数属性
| 类型: | Uri |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | 1 |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输入
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