Get-PSRepository

获取 PowerShell 存储库。

语法

Get-PSRepository
   [[-Name] <String[]>]
   [<CommonParameters>]

说明

Get-PSRepository cmdlet 获取为当前用户注册的 PowerShell 模块存储库。

示例

示例 1:获取所有模块存储库

PS C:\> Get-PSRepository
Name                                     SourceLocation                                     OneGetProvider       InstallationPolicy
----                                     --------------                                     --------------       ------------------
PSGallery                                http://go.micro...                                 NuGet                Untrusted
myNuGetSource                            https://myget.c...                                 NuGet                Trusted

此命令获取为当前用户注册的所有模块存储库。

示例 2:按名称获取模块存储库

PS C:\> Get-PSRepository -Name "*NuGet*"

此命令获取名称中包含 NuGet 的所有模块存储库。

示例 3:获取模块存储库并设置输出格式

PS C:\> Get-PSRepository -Name "Local01" | Format-List * -Force
Name                      : local01
SourceLocation            : http://manikb-dev:8765/api/v2/
Trusted                   : True
Registered                : True
InstallationPolicy        : Trusted
PackageManagementProvider : NuGet
PublishLocation           : http://pattif-dev:8765/api/v2/package/
ScriptSourceLocation      : http://pattif-dev:8765/api/v2/artifacts/psscript
ScriptPublishLocation     : http://pattif-dev:8765/api/v2/package/
ProviderOptions           : {}

此命令获取名为 Local01 的存储库,并使用管道运算符将该对象传递给 Format-List cmdlet。

参数

-Name

指定要获取的存储库的名称。

类型:String[]
Position:0
默认值:None
必需:False
接受管道输入:True
接受通配符:False