Registrare un repository di PowerShellRegister a PowerShell Repository

È possibile configurare PowerShellGet per agire su repository interni.You can configure PowerShellGet to operate against internal repositories. Ciò avviene tramite le seguenti aggiunte:This is done by using the following additions:

  • Register-PSRepository: registra un repository per l'utente corrente.Register-PSRepository: Registers a repository for the current user.
  • Unregister-PSRepository: rimuove un repository registrato per l'utente corrente.Unregister-PSRepository: Removes a registered repository for the current user.
  • Set-PSRepository: imposta i valori per un repository registrato.Set-PSRepository: Set values for a registered repository.
  • Get-PSRepository: ottiene tutti i repository registrati per l'utente corrente.Get-PSRepository: Get all registered repositories for the current user.

Dopo aver registrato un repository, è possibile usare Find-Module e Install-Module per usarlo.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 “” –PublishLocation “<>/package” –InstallationPolicy –Trusted

\#Get all of the registered repositories
Name SourceLocation
---- --------------
PSGallery https://msconfiggallery.cloudapp...

\#Search only the new repository for modules
Find-Module -Repository DemoRepo
Repository Version Name
---------- ------- ----
DemoRepo 1.0.1 xActiveDirectory
DemoRepo 1.1.1 SomeModule

\#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