Over the past couple weeks, while we’ve all been focused on the news on Windows 8.1 Update, Windows Phone 8.1, Microsoft Azure, and Heartbleed, there’s also been a number of significant enhancements and announcements regarding PowerShell – including a preview release of the next major PowerShell version, Windows PowerShell 5.0.

Click to enlarge ...

This article is the first in a series of articles designed to highlight recent announcements and new features in Windows PowerShell.  Today, I’ll help you get started with OneGet in PowerShell 5.0, but stay tuned for other articles in this series in the coming days …

Get the PowerShell 5.0 Preview

A Preview of Windows PowerShell 5.0 is included with the recently released Windows Management Framework (WMF) 5.0 Preview.  This Preview includes updates to Windows PowerShell, PowerShell Desired State Configuration (DSC) and the Windows PowerShell Integrated Scripting Environment (ISE).

Windows PowerShell 5.0 also includes two new modules: OneGet and NetworkSwitch. To evaluate these new features, you’ll need to download and install WMF 5.0 Preview in your lab …

Special note: Pay particular attention to the list of supported operating systems and applications on the download page for this Preview release of WMF 5.0.  In particular, systems running System Center 2012 Configuration Manager, System Center Virtual Machine Manager 2008 R2, Microsoft Exchange Server 2007 and Windows Small Business Server 2011 Standard should not run this WMF 5.0 Preview release.

Why use OneGet?

The OneGet module provides a new way to discover and install software packages from web-based repositories.  This first version of OneGet installs and searches from Chocolatey repositories, with support for additional repositories expected in subsequent versions.

OneGet can be leveraged to quickly install add-on software components when developing a new master PC image or when building custom environments for client and server applications – without needing to manually install each and every component. And … getting started with OneGet is super-easy!

Getting Started with Windows PowerShell OneGet

Let’s get started with OneGet and PowerShell 5.0 by using just a few new cmdlets from the OneGet module …

  1. Launch the Windows PowerShell ISE as Administrator.
     
  2. Confirm that you are using the RemoteSigned execution policy in PowerShell.
     
    Set-ExecutionPolicy RemoteSigned
     
  3. Import the OneGet module.
     
    Import-Module –Name OneGet
     
  4. List the available OneGet cmdlets.
     
    Get-Command –Module OneGet
     
  5. Find packages that can be installed via OneGet.
     
    Find-Package | Out-Gridview
     
    When prompted to install the NuGet Package Manager, click the Yes button to confirm.
     
  6. As of this article’s date, there are over 1,700 packages that can be installed via OneGet!
     
    Find the exact number of available packages with this command line:
     
    @(Find-Package).Count
     
  7. Select one or more packages to install on your local PC.
     
    Find-Package |
    Out-GridView `
      -Title "Select Packages to Install" `
      -PassThru |
    Install-Package –Force
     
  8. Confirm that the packages installed successfully.
     
    Get-Package 

Build a new Master PC Image with OneGet in record time!

Some master PC images can be pretty complex, with lots of 3rd party software and other tools preinstalled.  OneGet has the potential to help us simplify this process into four (4) general steps … using only one-line of PowerShell code!

  1. Install Windows 8.1 on a fresh PC that will serve as your new master image.
     
    Do not connect to your Active Directory domain or a Microsoft account. Instead, setup a local account.
     
  2. Use OneGet to install the required components.
     
    For instance, for building my new workstation image, I may need to install several 3rd party tools as part of the standard build process.  I can easily do this with OneGet using a single PowerShell command line
     
    Find-Package `
      -Name adobereader, `
            7zip, `
            paint.net, `
            notepadplusplus, `
            skype
     |
    Install-Package -Force

     
  3. Run through Windows Update and apply all necessary updates.
     
  4. Prepare the PC for imaging.
     
    cd \windows\system32\sysprep
    sysprep.exe /generalize /oobe /shutdown

Done! This is just one example of how OneGet can tremendously simplify typical IT Pro tasks.

Additional resources …

Of course, there’s lots more that can be done via OneGet, and Mike F Robbins has a great series of articles that he’s been building on this very topic over on his blog.

How are you planning to leverage OneGet?

Do you have a particular scenario or unique idea that you’re looking to automate with OneGet and Windows PowerShell 5.0? Share your thoughts and questions in the Comments area below …