Table of contents
Collapse the table of content
Expand the table of content

Cmdlets PackageManagement

OpenLocalizationService|Última actualización: 12/12/2016
1 Colaborador

Este es el núcleo de PackageManagement para admitir la detección, la instalación y el inventario de software (SDII). Pruebe los cmdlets para estas operaciones:

  • Find-Package
  • Find-PackageProvider
  • Get-Package
  • Get-PackageProvider
  • Get-PackageSource
  • Import-PackageProvider
  • Install-Package
  • Install-PackageProvider
  • Register-PackageSource
  • Save-Package
  • Set-PackageSource
  • Uninstall-Package
  • Unregister-PackageSource

Dado que PackageManagement es un módulo de PowerShell, puede hacer lo siguiente para actualizar PackageManagement:

PS C:\> Install-Module PackageManagement –Force

En este caso, deberá volver a iniciar una sesión de PowerShell para cambiar a la nueva versión de PackageManagement.

Cmdlet Find-Package

Este cmdlet permite la detección de paquetes de software en los orígenes de paquetes disponibles mediante los proveedores de paquetes cargados.

# Find all available Windows PowerShell module packages from galleries registered
# with PowerShellGet provider
Find-Package -Provider PowerShellGet -Source PSGallery

# Find a package from a provider that is not yet installed
# This will bootstrap NuGet provider and then search for jquery package using NuGet
# with <> as source
Find-Package -Name jquery –Provider NuGet -Source

# Find package with name and version
# Here we are assuming that the user already registered using
# Register-PackageSource. You can specify either the provider or the source, or
# neither. For the latter, performance may be less optimal as it searches through all
# the providers and registered sources.
Find-Package -Name jquery –Provider NuGet –RequiredVersion 2.1.4 -Source

Cmdlet Find-PackageProvider

El cmdlet Find-PackageProvider busca proveedores de PackageManagement coincidentes que estén disponibles en los orígenes de paquetes registrados con PowerShellGet. Estos son los proveedores de paquetes disponibles para la instalación con el cmdlet Install-PackageProvider. De forma predeterminada, se incluyen los módulos disponibles en la Galería de PowerShell con las etiquetas "PackageManagement" y "Provider".

Find-PackageProvider también busca proveedores de PackageManagement coincidentes que estén disponibles en el almacén de blobs de Azure de PackageManagement donde se usa el proveedor de programa previo de PackageManagement para buscarlos e instalarlos.

#Find all available package providers in PackageManagement azure blob store as well as in

#Find all versions of a provider
Find-PackageProvider -Name "Nuget" -AllVersions

#Find a provider from a specified source
Find-PackageProvider -Name "Gistprovider" -Source "PSGallery"

Cmdlet Get-Package

Este cmdlet devuelve una lista de todos los paquetes de software instalados con PackageManagement.

# Get all the packages installed by Programs provider
Get-Package –Provider Programs

# Get all the packages installed by NuGet provider at c:\test using the dynamic
# parameter destination
Get-Package –Provider NuGet -Destination c:\test

Cmdlet Get-PackageProvider

Los proveedores de paquetes que están cargados y listos para usar en el equipo local pueden incluirse en el inventario mediante el cmdlet.

# Get all currently loaded package providers

# The following cmdlet will show all the package providers available on the machine (including those that are not loaded):
Get-PackageProvider -ListAvailable

Cmdlet Get-PackageSource

Este cmdlet obtiene una lista de los orígenes de paquetes que están registrados para un proveedor de paquetes.

# Get all package sources

# Get all package sources for a specific provider
Get-PackageSource –ProviderName PowerShellGet

Cmdlet Import-PackageProvider

Este cmdlet agrega proveedores de paquetes de PackageManagement a la sesión actual.

# Import a package provider from the local machine
Import-PackageProvider –Name MyProvider

#The -Name parameter can be either the name of the provider or the full path to the provider. Currently, we support .dll, .exe and.psm1 for the full path case. If the name of the provider is used for the -Name parameter, then additional version parameters such as -RequiredVersion, -MinimumVersion and -MaximumVersion may be specified. Otherwise, the latest version of the provider will be imported.

#If a package provider is not yet loaded to your system, we can discover and install on-demand. You can use explicit discovery and install cmdlets to do so:
 Install-PackageProvider –Name MyProvider

#After installed, follow the Import-PackageProvider to load it to your system.

# Import a specific version of a package provider. PackageManagement supports installations of multiple versions of a package provider using PackageProvider cmdlets (not by bootstrapper provider). You can install another version of a package provider given that you already have one up running by:
Find-PackageProvider –Name "Nuget" -AllVersions
Install-PackageProvider -Name "Nuget" -RequiredVersion "" -Force
Get-PackageProvider –ListAvailable
Import-PackageProvider –Name "Nuget" -RequiredVersion "" -Verbose
Import-PackageProvider –Name MyProvider –RequiredVersion xxxx -force

Cmdlet Install-Package

Este cmdlet permite la instalación de paquetes de software en los orígenes de paquetes disponibles mediante los proveedores de paquetes cargados.

# Install a package by name.
# NuGet provider requires us to provide the dynamic parameter destination path
# when we use this provider to install. Not all providers will require you to supply
# dynamic parameters for PackageManagement cmdlets.
Install-Package -Name jquery -Source -Destination c:\test

# Install a package by piping.
Find-Package -Name jquery –Provider NuGet | Install-Package -Destination c:\test

Cmdlet Install-PackageProvider

Este cmdlet instala uno o varios proveedores de paquetes de PackageManagement.

# Install a package provider from the PowerShell Gallery
Install-PackageProvider –Name "Gistprovider" -Verbose

# Install a specified version of a package provider
Find-PackageProvider –Name "Nuget" -AllVersions
Install-PackageProvider -Name "Nuget" -RequiredVersion "" -Force

# Find a provider and install it
Find-PackageProvider –Name "Gistprovider" | Install-PackageProvider -Verbose

# Install a provider to the current user’s module folder
Install-PackageProvider –Name Gistprovider –Verbose –Scope CurrentUser

Cmdlet Register-PackageSource

Este cmdlet agrega un origen de paquete para un proveedor de paquetes especificado. Cada proveedor de PackageManagement puede tener uno o varios orígenes de software o repositorios. PackageManagement proporciona cmdlets de PowerShell para agregar, quitar o consultar el origen. Por ejemplo, puede registrar un origen de paquete para el proveedor de NuGet:

Register-PackageSource -Name "NugetSource" -Location "" –ProviderName nuget

Cmdlet Save-Package

Este cmdlet guarda los paquetes en el equipo local sin instalarlos.

# Saves jquery package to c:\test using NuGetProvider
# Notes that the -Path parameter must point to an existing location
Save-Package -Name jquery –Provider NuGet -Path c:\test

# Save a package by piping.
Find-Package -Name jquery -Source | Save-Package -Path c:\test
Find-Package -source c:\test

Cmdlet Set-PackageSource

Este cmdlet cambia información sobre un origen de paquete existente.

#Set-PackageSource changes the values for a source that has already been registered by running the Register-PackageSource cmdlet. By #running Set-PackageSource, you can change the source name and location.
Set-PackageSource  -Name -Location -NewName nuget2 -NewLocation

Cmdlet Uninstall-Package

Este cmdlet desinstala los paquetes instalados en el equipo local.

# Uninstall jquery using nuget
Uninstall-Package -Name jquery –Provider NuGet -Destination c:\test

# Uninstall a package with by piping with Get-Package
Get-Package -Name jquery –Provider NuGet -Destination c:\test | Uninstall-Package

Cmdlet Unregister-PackageSource

# Unregister a package source for the NuGet provider. You can use command Unregister-PackageSource, to disconnect with a repository, and Get-PackageSource, to discover what the repositories are associated with that provider.
Unregister-PackageSource  -Name "NugetSource"
© 2017 Microsoft