One very cool thing in the last Windows Management Framework V5 Preview release is the new module OneGet which allow us to manage a list of software repositories, search/acquire/install/uninstall package(s).
This has been present in the Linux world for a very long time, for example with APT-GET (Debian). This new feature is basically a global silent installer for applications and tools. We should also be able to do configuration tasks and anything that you can do with PowerShell. The power you hold with a module like OneGet is only limited by your imagination! :-)
Note that this is a preview, there is no documentation yet, the features and behavior are likely to change before the final release.
OneGet Module ?
OneGet is a new way to discover and install software packages from around the web. With OneGet, you can:
* Manage a list of software repositories in which packages can be searched, acquired, and installed
* Search and filter your repositories to find the packages you need
* Seamlessly install and uninstall packages from one or more repositories with a single PowerShell command
Here is a list of the Cmdlets coming with this new module
Get-Command -Module OneGet
CommandType Name Source ----------- ---- ------ Cmdlet Add-PackageSource OneGet Cmdlet Find-Package OneGet Cmdlet Get-Package OneGet Cmdlet Get-PackageSource OneGet Cmdlet Install-Package OneGet Cmdlet Remove-PackageSource OneGet Cmdlet Uninstall-Package OneGet
For now, there is not much information in the help but the naming convention is explicit and we can easily understand the role of each of those:
|Add-PackageSource||Add a new Software Repository|
|Find-Package||Search a package from one or more repositories|
|Get-Package||Get the package installed locally|
|Get-PackageSource||Get the Software Repositories|
|Install-Package||Install a Package|
|Remove-PackageSource||Remove a Package Source|
|Uninstall-Package||Uninstall a Package|
|No help or examples for now (Find-Package Cmdlet)|
Additional Cmdlet Get-PackageProvider ?
Note that we can also expect a new cmdlet called Get-PackageProvider</b>in the final version from what we see in the manifest.
From my understanding this is how the OneGet module interact with the package manager like Chocolatey.
Load OneGet module in PowerShell. OneGet is the common interface for interacting with any Package Manager (Plugins).
Then use a Provider for each Package Manager that plugs into OneGet. (Providers do all of the actual work, fetching content from the repositories and doing the actual installation.)
The package manager will then query its software repository to retrieve the package. In this example Chocolatey use it’s own set of Cmdlets (see below in this post)
The package manager then download a configuration file OR get the URI where it will find the instruction to install the package. In the case of Chocolatey, a configuration file is downloaded from the repository and saved locally in C:\Chocolatey\lib<APPNAME>\Tools,
- The Provider will then execute the configuration file and download the actual software (+ its dependencies) from a repository, and obviously install it…. silently :-)
Chocolatey Cmdlets If we look at the files in the module directory, Chocolatey comes with its own set of Cmdlets. (Available on the Chocolatey GitHub repo) C:\Windows\System32\WindowsPowerShell\v1.0\Modules\OneGet
|Chocolatey Provider Cmdlets Helpers (Helpers.psm1)|
|Chocolatey Cmdlets (Chocolatey.psd1)|
Using the module
Get the packages already installed
Since I’ve been using chocolatey for a while, Using Get-Package</b>, OneGet is able to retrieve the all the package I installed on this PC.
Find and install a new package
Now if I want to install a package, that’s very easy: Install-Package</b> We first search for the package
# We first query our provider for a package called putty Find-Package -Name putty | fl *
# Then we install the package Find-Package -Name putty | Install-Package -Verbose
|PowerShell is download the configuration file the repository and execute it Then Posh/OneGet is downloading the package (note the package it's not actually located on the chocolatey website)|
The file are download and unzipped inC:\Chocolatey\lib directory by default.
Install-ChocolateyZipPackage 'putty' 'http://the.earth.li/~sgtatham/putty/latest/x86/putty.zip' "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
Also note there is some interesting parameters in the Install-Package cmdlet:
* InstallationOptions [hashtable]
* InstallArguments [String]
Find and install one/multiple package(s) using Out-GridView
+Jeffrey Snoveralso shared a very smart line on twitter on how to use a small “GUI” to Select one or multiple packages you want to install:
# Using Out-GridView -PassThru to select the Packages
Find-Package | Out-Gridview -PassThru | Install-Package -Verbose
The other cool thing with Out-GridView is that you can also filter on multiple property
Uninstalling a package
# Get the package putty installed locally Get-Package putty
# Get and Uninstall putty Get-Package putty | Uninstall-Package -Verbose