10 Windows: Install software with PowerShell [Quick Guide]

2:00 am January 27, 201712256

I. introduction

directly from the Open Source project “ OneGet ‘, Microsoft for implemented a new module PowerShell within Windows 10 named” PackageManagement ‘ which allows to manage the software command-line.»» In other words, the closer use like under Linux where you can install software from a simple command with the very famous “ apt – get install “. ”

in summary, PackageManagement is a usable via PowerShell package manager . Typically, this can be used to automate the installation of software on a freshly installed machine, and this can replace Ninite tools like .

note: for those who are interested in Nano Server, there is a specific provider named “ NanoServerPackage

it will also be interesting to be able to automate the installation of several software through a PowerShell script with this module.”

this module is reserved for PowerShell 5, for versions 3 and 4 of PowerShell, please refer to this link: PackagementManagement PowerShell V3 and V4

II. Orders of PackageManagement

to list the commands available within this module, nothing more simple one seizes in a PowerShell console:

 Get-Command - Module PackageManagement 

in the current version 1.0.0.1 of the module, here are the commands available:

Find-Package : search for a package within the sources of available packages
Get-Package : Returns a list of all the installed packages
Get-PackageProvider : Returns the list of suppliers of packages (deposits) used on the machine
Get-PackageSource : Returns the list of available sources to retrieve packages
Install-Package : install a package (software) on the machine
Register-PackageSource : Add a source within a provider
Save-Package : Save a local package without installing it
Set PackageSource : set a provider as a source for packages
Uninstall Package : uninstall a package (software)
Unregister-PackageSource : remove use a provider of sources for packages

you can find help on the Developer Network Microsoft: Microsoft PackageManagement (OneGet)

PackageManagement uses the principle of the Chocolatey software that allows to install software command-line You can read my tutorial about it if this interests you as Chocolatey can very well be used on Windows 10: Chocolatey on Windows 10

Besides, Chocolatey done out of the providers available for installing software in PowerShell.

III. Find and install a provider

to list all of the available providers, we will use the following command:

 Find-PackageProvider 

This gives us sources that can be used to retrieve packages online, it is essential to start with this step. Let’s add chocolatey that contains far more than 4,300 packages.

to install a new provider, use the following command:

 Install-PackageProvider chocolatey 

specify “ O ‘ to ‘ yes ‘ to validate the installation. Giving:

chocolatey-provider-1

Note: by default, the provider “ PSGallery ‘ is already installed because it allows to search for PowerShell modules on the Microsoft online gallery.

we’ll take the opportunity to define Chocolatey as a trusted source for download of packages, which don’t have a confirmation to install each application:

 PS C:WINDOWSsystem32 > Set-PackageSource - Name chocolatey - Trusted Name ProviderName IsTrusted rental - - - - chocolatey Chocolatey True http://chocolatey.org/api/v2/ 

right now is Chocolatey part sources for installing software in PowerShell :

 PS C:WINDOWSsystem32 > Get - PackageSource Name ProviderName IsTrusted rental ----PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2/ chocolatey Chocolatey False http://chocolatey.org/api/v2/ 

turn now on a concrete case with the installation of a package via Chocolatey.

IV. Install a package from the repositories Chocolatey

first, it is interesting to search the package within our deposits in order to find its exact name. In this tutorial, I take for example the installation of Adobe Reader it’ll give me the opportunity to install it on my machine…

useful link: Chocolatey package list

you can directly check the existence of a package with the command ‘ Find-Package “but if you do not know the exact name, it is best to frame your key word with asterisks * which allows to search for this term. Here is a screenshot with examples and a correct command:

 Find-Package - Name * Adobe *-Source Chocolatey 

is not required to specify the source for search the package, but it may be useful if you have several sources defined on your desktop and you want to prioritize one.

packagemanagement-2

to install the package using the Chocolatey provider that hosts the package you want, use this command:

 Install-Package - Name AdobeReader - ProviderName Chocolatey 

if we had not agreed Chocolatey as reliable source, this would have been proposed during the first installation. See for yourself:

packagemanagement-4

at the top of your window PowerShell, progress regarding the download of Adobe Reader is indicated, then the application will install itself in all transparency.

packagemanagement-3

after a few minutes of patience, Acrobat Reader DC is well installed on your machine!

packagemanagement-5

you no longer have that to install your software order online, now no longer an excuse 😉