PackageManagement-cmdletsPackageManagement Cmdlets

Dit is de kern van PackageManagement ter ondersteuning van software-detectie, installatie en -inventarisatie (SDII).This is the core of PackageManagement to support software discovery, installation, and inventory (SDII). Probeer de cmdlets voor deze bewerkingen uit:Try out the cmdlets for these operations:

  • Zoek-pakketFind-Package
  • Zoeken naar PackageProviderFind-PackageProvider
  • Get-PackageGet-Package
  • Get-PackageProviderGet-PackageProvider
  • Get-PackageSourceGet-PackageSource
  • Importeren PackageProviderImport-PackageProvider
  • Install-PackageInstall-Package
  • Installatie PackageProviderInstall-PackageProvider
  • Register PackageSourceRegister-PackageSource
  • Opslaan-pakketSave-Package
  • Set-PackageSourceSet-PackageSource
  • Verwijderen van pakketUninstall-Package
  • Hef de registratie van PackageSourceUnregister-PackageSource

Als PackageManagement een PowerShell-module is, kunt u het volgende als u wilt bijwerken PackageManagement zelf doen:As PackageManagement is a PowerShell module, you can do the following to update PackageManagement itself:

PS C:\> Install-Module PackageManagement –Force

In dit geval moet u PowerShell-sessie overschakelen naar de nieuwe versie van PackageManagement opnieuw invoeren.In this case, you will have to re-enter PowerShell session to switch to the new version of PackageManagement.

Zoeken naar pakket CmdletFind-Package Cmdlet

Met deze cmdlet kan de detectie van softwarepakketten in beschikbaar pakket gegevensbronnen waarvoor gebruik wordt geladen pakket providers.This cmdlet allows discovery of software packages in available package sources using loaded package providers.

# 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 <http://www.nuget.org/api/v2/> as source
Find-Package -Name jquery –Provider NuGet -Source http://www.nuget.org/api/v2/

# Find package with name and version
# Here we are assuming that the user already registered nuget.org 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 nuget.org

Zoeken naar PackageProvider CmdletFind-PackageProvider Cmdlet

De cmdlet zoeken PackageProvider zoeken naar overeenkomende PackageManagement providers die beschikbaar in het pakket gegevensbronnen die zijn geregistreerd met PowerShellGet zijn.The Find-PackageProvider cmdlet finds matching PackageManagement providers that are available in package sources registered with PowerShellGet. Dit zijn pakket providers beschikbaar voor installatie met de cmdlet Install-PackageProvider.These are package providers available for installation with the Install-PackageProvider cmdlet. Standaard bevat deze modules beschikbaar in de PowerShell-galerie met de 'PackageManagement' en 'Provider' labels.By default, this includes modules available in the PowerShell Gallery with the 'PackageManagement' and 'Provider' Tags.

Zoeken naar PackageProvider vindt ook overeenkomende PackageManagement providers die beschikbaar in de PackageManagement azure blob-opslag waar we de PackageManagement boostrapper provider gebruiken zijn voor het zoeken en installeren.Find-PackageProvider also finds matching PackageManagement providers that are available in the PackageManagement azure blob store where we use the PackageManagement boostrapper provider for finding and installing them.

#Find all available package providers in PackageManagement azure blob store as well as in PowerShellGallery.com
Find-PackageProvider

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

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

De Cmdlet Get-pakketGet-Package Cmdlet

Deze cmdlet retourneert een lijst van alle softwarepakketten die zijn geïnstalleerd met behulp van PackageManagement.This cmdlet returns a list of all software packages that have been installed using 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

De Cmdlet Get-PackageProviderGet-PackageProvider Cmdlet

Pakket-providers die worden geladen en klaar voor gebruik op de lokale computer kunnen worden geïnventariseerd met de cmdlet.Package providers that are loaded and ready to be used on the local machine can be inventoried by using the cmdlet.

# Get all currently loaded package providers
Get-PackageProvider

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

De Cmdlet Get-PackageSourceGet-PackageSource Cmdlet

Deze cmdlet wordt een lijst met pakket-bronnen die zijn geregistreerd voor een Pakketprovider.This cmdlet gets a list of package sources that are registered for a package provider.

# Get all package sources
Get-PackageSource

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

De Cmdlet import-PackageProviderImport-PackageProvider Cmdlet

Deze cmdlet wordt Package Management pakket providers toegevoegd aan de huidige sessie.This cmdlet adds Package Management package providers to the current session.

# 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:
 Find-PackageProvider
 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 "2.8.5.201" -Force
Get-PackageProvider –ListAvailable
Import-PackageProvider –Name "Nuget" -RequiredVersion "2.8.5.201" -Verbose
Import-PackageProvider –Name MyProvider –RequiredVersion xxxx -force

De Cmdlet Install-Package Install-Package Cmdlet

Met deze cmdlet kan de installatie van softwarepakketten in beschikbaar pakket gegevensbronnen waarvoor gebruik wordt geladen pakket providers.This cmdlet allows installation of software packages in available package sources using loaded package providers.

# 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 nuget.org -Destination c:\test

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

De Cmdlet Install-PackageProviderInstall-PackageProvider Cmdlet

Deze cmdlet wordt een of meer Management pakket met pakket-providers geïnstalleerd.This cmdlet installs one or more Package Management package providers.

# 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 "2.8.5.201" -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

De Cmdlet register-PackageSourceRegister-PackageSource Cmdlet

Deze cmdlet wordt een pakketbron toegevoegd voor een opgegeven pakket-provider.This cmdlet adds a package source for a specified package provider. Elke provider PackageManagement misschien op een of meerdere software-bronnen of -opslagplaatsen.Each PackageManagement provider may have one or multiple software sources, or repositories. PackageManagement biedt PowerShell-cmdlets voor toevoegen/verwijderen/query de bron.PackageManagement provides PowerShell cmdlets to add/remove/query the source. U kunt bijvoorbeeld een pakketbron registreren voor de NuGet-provider:For example, you can register a package source for the NuGet provider:

Register-PackageSource -Name "NugetSource" -Location "http://www.nuget.org/api/v2" –ProviderName nuget

Cmdlet opslaan-pakketSave-Package Cmdlet

Deze cmdlet slaat pakketten op de lokale computer zonder ze te installeren.This cmdlet saves packages to the local computer without installing them.

# 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 http://www.nuget.org/api/v2/ | Save-Package -Path c:\test
Find-Package -source c:\test

De Cmdlet set-PackageSourceSet-PackageSource Cmdlet

Deze cmdlet wordt informatie over een bestaande pakketbron gewijzigd.This cmdlet changes information about an existing package source.

#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 nuget.org -Location  http://www.nuget.org/api/v2 -NewName nuget2 -NewLocation https://www.nuget.org/api/v2

De Cmdlet Uninstall-pakketUninstall-Package Cmdlet

Deze cmdlet verwijdert pakketten die zijn geïnstalleerd op de lokale computer.This cmdlet uninstalls packages installed on the local computer.

# 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

Hef de registratie van PackageSource CmdletUnregister-PackageSource Cmdlet

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