Register PSRepositoryRegister-PSRepository

Hiermee haalt u de geregistreerde opslagplaatsen op een computer.Gets the registered repositories on a computer.

BeschrijvingDescription

De cmdlet Register-PSRepository registreert de onlineopslagplaats voor PowerShell-modules.The Register-PSRepository cmdlet registers the online repository for PowerShell modules. Nadat een opslagplaats is geregistreerd, u ernaar kunt verwijzen vanuit de Find-Module installeren-Module en de cmdlets Publish-Module.After a repository is registered, you can reference it from the Find-Module, Install-Module, and Publish-Module cmdlets. De geregistreerde opslagplaats, wordt de standaard-opslagplaats in zoek-Module en installatie-Module.The registered repository becomes the default repository in Find-Module and Install-Module.

Geregistreerde opslagplaatsen zijn specifiek voor een gebruiker.Registered repositories are user-specific. Ze zijn niet geregistreerd in een context van het gehele systeem.They are not registered in a system-wide context.

De syntaxis van cmdletCmdlet syntax

Get-Command -Name Register-PSRepository -Module PowerShellGet -Syntax

Verwijzing naar het online help van cmdletCmdlet online help reference

Register PSRepositoryRegister-PSRepository

VoorbeeldopdrachtenExample commands

Registreren van een PowerShell-opslagplaatsRegister a PowerShell Repository

U kunt PowerShellGet werken tegen interne opslagplaatsen configureren.You can configure PowerShellGet to work against internal repositories. Nadat een opslagplaats is geregistreerd, kunt u zoeken-Module en installatie-Module om hiermee te werken.After a repository is registered, you can use Find-Module and Install-Module to work with it.

# Register a default repository
Register-PSRepository –Name DemoRepo –SourceLocation "https://www.myget.org/F/powershellgetdemo/api/v2" –InstallationPolicy Trusted

# Get all of the registered repositories
Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2/
DemoRepo                  Trusted              https://www.myget.org/F/powershellgetdemo/api/v2


# Search only the new repository for modules
Find-Module -Repository DemoRepo

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
2.12.0.0   xActiveDirectory                    DemoRepo             The xActiveDirectory module is originally part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit. This version has been modified for use in Azure. This module contains the xADD...
1.1.1      SomeModule                          DemoRepo             Module description.

# By default, PowerShellGet operates against all registered repositories when none is specified. In this example, the “SomeModule” module is installed from the DemoRepo.
Install-Module SomeModule

# Removing a repository
Unregister-PSRepository DemoRepo

Register PSRepository en Set-PSRepository cmdlets met script-ondersteuning voor delenRegister-PSRepository and Set-PSRepository cmdlets with script sharing support

De cmdlet Register-PSRepository gebruiken om toe te voegen de ScriptSourceLocation en ScriptPublishLocation naar de PSRepository.Use Register-PSRepository cmdlet to add the ScriptSourceLocation and ScriptPublishLocation to the PSRepository.


# Register an GalleryINT repository with Scripts and Modules support

Register-PSRepository -Name GalleryINT `
                      -SourceLocation https://customgallery.cloudapp.net `
                      -InstallationPolicy Trusted `
                      -Verbose

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program
Files\PackageManagement\ProviderAssemblies' or 'C:\Users\manikb\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
VERBOSE: Installing NuGet provider.
VERBOSE: The specified assembly 'C:\Program Files\PackageManagement\ProviderAssemblies\nuget-anycpu.exe' is installed at top level directory. However it is recommended that the assemblies
should be installed under its ProviderName\Version folder.
VERBOSE: Installing the package 'https://oneget.org/nuget-2.8.5.201.package.swidtag'.
VERBOSE: Installed the package 'nuget' to 'C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.201\Microsoft.PackageManagement.NuGetProvider.dll'.
VERBOSE: The provider 'NuGet' has already been imported. Trying to import it again.
VERBOSE: Importing package provider 'NuGet'.
VERBOSE: Performing the operation "Register Module Repository" on target "Module Repository 'GalleryINT' (https://customgallery.cloudapp.net/) in provider 'PowerShellGet'".
VERBOSE: User did not specify the PackageManagement provider name, trying with the provider name 'NuGet'.
VERBOSE: Successfully registered the repository 'GalleryINT' with source location 'https://customgallery.cloudapp.net/api/v2/'.
VERBOSE: Repository details, Name = 'GalleryINT', Location = 'https://customgallery.cloudapp.net/api/v2/'; IsTrusted = 'True'; IsRegistered = 'True'.

# Get the registered repository details
Get-PSRepository -Name GalleryINT

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
GalleryINT                 Trusted              https://customgallery.cloudapp.net/api/v2/


Get-PSRepository -Name GalleryINT | Format-List * -Force

Name : GalleryINT
SourceLocation : https://customgallery.cloudapp.net/api/v2/
Trusted : True
Registered : True
InstallationPolicy : Trusted
PackageManagementProvider : NuGet
PublishLocation : https://customgallery.cloudapp.net/api/v2/package/
ScriptSourceLocation : https://customgallery.cloudapp.net/api/v2/items/psscript/
ScriptPublishLocation : https://customgallery.cloudapp.net/api/v2/package/
ProviderOptions : {}