5 Minute setup: Using OneGet with Chocolatey in Windows 10

OneGet is to Windows what apt-get and yum are  to Linux.

Back in April of this year, Jeffrey Snover from the Windows Server team, teased the power of a new package management program coming to Windows called OneGet.

The beauty of OneGet is that it gives you access to over 2,300 software packages directly from the command line.  There’s no need to visit the stupid Microsoft Store or sift through Google search results.  You can now install hundreds of packages directly from the Powershell command line with ease.

Moreover not only let’s you install and uninstall packages with simple commands but you can also easily search through repositories so you can grab exactly what you need.

It’s really a beautiful thing and today I’m going to show you how to use it.

Here’s how to get started.

Getting OneGet

Fire up Windows 10, kick open PowerShell and type:

Import-Module -Name OneGet

Using PowerShell to Import OneGet

After a few seconds the command prompt will return awaiting your input.

So what can we do with OneGet?

We’ll lets list the command and see!

Type:

Get-Command -Module OneGet

Get-Command -Module OneGet

I’m seeing:

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

The first thing we need to do is add a monster software repository called Chocolatey.

Adding Chocolatey to OneGet

By default you’ll only see the PSGallery and MSPSGallery repos but these guys are very limited.  SO we need the delicious chocolatey repo.  And I mean – with a name like “chocolatey” who can resist it?

If you search the web you’ll see a few people using the Add-PackageSource cmdlet to add the Chocolatey repository.  But in the Windows 10 Technical Preview, Add-PackageSource was actually replaced with Register-PackageSource so that’s what I’m using.

Here’s the command we need to use to add the Chocolatey repo into OneGet:

Register-PackageSource -Name chocolatey -Location http://chocolatey.org/api/v2 -Provider PSModule -Trusted -Verbose

Adding Chocolatey to OneGet!Now we can have some serious fun.

First, head on over to chocolatey.org/packages to see all the packages at your disposal.

Viewing Chocolatey packages

Let’s say I want to install Google Chrome.  I can search for it:

Find-Package -Name Chrome

Finding Packages with OneGet

Or just install it like so:

Install-Package -Name GoogleChrome

Try experimenting with different package names.  For example put in:

  • Install-Package -Name VLC
  • Install-Package -Name Firefox
  • Install-Package -Name flashplayerplugin

You can also easily uninstall programs with the Uninstall-Package cmdlet.

Nice eh?

The Bottom Line

There’s got to be a way to list packages from the command line but I haven’t  figured that out yet.  If you know please share in the comments.

Also, although I can easily install and uninstall packages, I haven’t found an Update-Package cmdlet.  This would be extremely useful and I hope Microsoft considers adding it.

So what do think about OneGet?  Will Microsoft use this as a way to install ModernUI Apps?

I personally don’t see that happening because this tool is better suited for Powerusers but I guess the possibility is there.  Let me know what you think in the comments below!

About

Connect with Vonnie on Twitter

Posted in Windows, Windows 10 Tagged with: , ,
  • DanielHilgarth

    I may be missing something, but why not just use chocolatey directly?

    • narg

      OneGet is the tool, Chocolatey is mainly a repository, though install tools are available there. If OneGet is included in Windows 10 though, it’s only going to open the doors to more manageable package distribution. On an administrator side, not the end user. Something that’s been missing from Windows’ core features for a long time.

  • Steven Luker

    It’s picking up both: WARNING: ‘VLC’ matched package ‘vlc/2.1.5.20140811’ from provider: ‘Chocolatey’, source ‘chocolatey’

    WARNING: ‘vlc’ matched package ‘vlc/2.1.5.20140811’ from provider: ‘PSModule’, source ‘http://chocolatey.org/api/v2/’

    • Ginger Rojas

      Oneget is renmaed to PackageManagement

      so it will work for

      Get-Command -Module PackageManagement

  • Liju George

    find-package dumps out the whole list onto the powershell console

  • Schikitar

    This doesn’t appear to be working in build 10049, sorry about the output below, I just copied/paste from PS…
    PS C:WINDOWSsystem32> Register-PackageSource -Name chocolatey -Location http://chocolatey.org/api/v2 -Provider PSModule -Trusted -Verbose

    WARNING: Unable to find package provider ‘PSModule’.
    Register-PackageSource : Unable to find package providers (PSModule.
    At line:1 char:1
    + Register-PackageSource -Name chocolatey -Location http://chocolatey.o
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (Microsoft.Power…erPackageSource:RegisterPackageSource) [Register-Pac
    kageSource], Exception
    + FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.OneGet.Cmdlets.RegisterPackageSource

    • I have same issue…

    • mamoru

      the syntax seems to have changed recently.
      I managed to get chocolatey added by changing the “-provider PSModule” bit to “-ProviderName -PSModule”

  • krizz

    i think there is no reason to use oneget yet, because we are not able to update a package… i hope that will change soon…

  • Stu

    I tried Import-Module -Name OneGet and it says “Import-Module : The specified module ‘OneGet’ was not loaded because no valid module file was found in any module directory.

    • Goddard

      Same issue here…do you need a different version of Windows for this to work?

      • With W10’s release, you don’t need to import the module, PackageManager (it’s now called that in windows 10) is included by default.

  • morpk

    to list all packages just use “Find-Package” and it will list everything in the repository

  • morpk

    so every time I try and install something I get the following error “WARNING: The module ‘notepadplusplus’ cannot be installed or updated because it is not a properly-formed module.”

  • morpk

    ok found a fix for installing issues
    instead of running “install-package -Name vlc” run “choco install vlc”
    or “choco install notepadplusplus” and it has been working for me

  • Roman C

    Can I set a specific install path for packages?