For the ones who do not know yet, PowerShell oneGet is a tool that will allow you to manage, your applications on a machine using Powershell.

If you are familiar to Linux apt-get then you you will feel like home reading this blog post.

 

PowerShell oneGet is only available in Powershell version 5.0

How can I find the powershell version I am using?

There is nothing easier to do in your prompt, use the $PsVErsionTable command to see what powershell version you have installed.

You will have a smiliar return as in the screen shot below. Be sure that psVersion value is at least 5.0.x

PowerShell version

$PsVersionTable

If you are missing the powershell 5.0, you can get it right here. Be sure to run a Update-Help to get the latest help files with it.

 

Let’s see the possibilities that we have :

 

Get-OneGet module commands

 

What does each cmdlet actually stands for?

If you haven’t updated your help since the installation of PowerShell 5.0, now is the moment to do it, otherwise the following trick won’t work.

Get the latest help files using the following cmdlet:

We have our list of cmdlets now, and the help is updated, but how can I have a short information, a one line description of each cmdlet? (Even though the PowerShell naming convention is pretty straight forward).

like this:

oneGet help

oneget basic help

The following cmdlets are available:

Name                     Synopsis     
Find-Package Finds software packages in available package sources.
Get-Package Returns a list of all software packages that have been installed by using OneGet.
Get-PackageProvider Returns a list of package providers that are connected to OneGet.
Get-PackageSource Gets a list of package sources that are registered for a package provider.
Install-Package Installs one or more software packages.
Register-PackageSource Adds a package source for a specified package provider.
Save-Package Saves packages to the local computer without installing them.
Set-PackageSource Replaces a package source for a specified package provider.
Uninstall-Package Uninstalls one or more software packages.
Unregister-PackageSource Removes a registered package source.

Using Find-package will allow you to retrieve all available packages on your current repository.

Why do I see so few packages ?

When I first used PowerShell oneGet, I only had 103 packages returned.

 

Oneget find-Package

oneGet find-Package -eq 103

I knew this number was incorrect, since I  read on various places on the internet that the number of packages was (at least) bigger then 1000+.

Let’s digg more into this!

The following two cmdlets will let you manage you OneGet provider and sources.

  • Get-PackageProvider
  • Get-PackageSource

When we launch them, this is what got returned.

 

Get-PackageProvider

Get-PackageProvider

Get-PackageSource

Get-PackageSource

 

I knew for sure that Chocaltey was suppose to be in the list. I know that most of the available packages are currently located on the Chocolatey repository.

How to add a oneget package source using powershell?

I added the Chocolatey packageSource using the following command line.

Register-PackageSource Chocolatey

Register-PackageSource Chocolatey

And if I launch the Find-Package cmdlet now…

find-package returns 2400 package

Find-Package, ready to rumble!

“Actually, it has 2805 today (April 12th 2015).”

How to install an application using powershell?

In order to install an application / package with powershell, we simple use the following command:

In the example below, I added the verbose switch to show that the package actually comes from the Chocolatey repository.

 

powershell oneget

There you go. Drop a comment if you liked, and don’t forget to read more about it in the resources section 🙂

Resources :

Online OneGet help page –> http://docs.nuget.org/docs/Reference/Package-Manager-Console-PowerShell-Reference

Very good article from my friend and “compatriote Français” FX, the lazy WinAdmin (who is actually not THAT lazy I have to say) –> http://www.lazywinadmin.com/2014/04/powershell-playing-with-new-oneget.html

A good article written by the scripting games winner and PowerShell MVP Mike F Robbins –> http://mikefrobbins.com/2014/04/07/installing-software-with-the-oneget-module-in-powershell-version-5/

http://www.fixedbyvonnie.com/2014/11/5-minute-setup-using-oneget-chocolatey-windows-10/#.VFxwx_mG8a0

By | 2016-10-19T21:00:14+00:00 April 12th, 2015|oneget, PowerShell|0 Comments

About the Author:

Stéphane is a dynamic and passionate Cloud and datacenter Microsoft MVP since. He is the founder of the Basel PowerShell user Group (BPUG), the co-founder of the French Speaking PowerShell UserGroup (FRPSUG), author, blogger, and received the community award "PowerShell Hero" from PowerShell.org. Stéphane has implemented microsoft infrastructure solutions in various countries of Europe and is currently working in Basel / Switzerland. Stéphane help his clients to reduce their global infrastructure costs by implementing Microsft infrastructure solutions by combining great products such as System Center, Windows Server, with heavy automation using Windows PowerShell. Stéphane loves languages, Belgium beer, French cheese and French Wine. If any of these topics are of your interest, don't hesitate to come and say hi.

Leave a Reply

%d bloggers like this: