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.
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 …
- DO IT: Download the VHD image of Windows Server 2012 R2
WMF 5.0 Preview is a pre-release that is not intended for installation on production servers. Downloading and installing a fresh copy of Windows Server 2012 R2 in a VM for lab testing provides a great way to do early evaluation of the new WMF 5.0 features. We even provide Windows Server 2012 R2 in a pre-packaged VHD image format to make it super-easy to spin up as a new VM.
- DO IT: Download the Windows Management Framework 5.0 Preview
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 …
- Launch the Windows PowerShell ISE as Administrator.
- Confirm that you are using the RemoteSigned execution policy in PowerShell.
- Import the OneGet module.
Import-Module –Name OneGet
- List the available OneGet cmdlets.
Get-Command –Module OneGet
- 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.
- 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:
- Select one or more packages to install on your local PC.
-Title "Select Packages to Install" `
- Confirm that the packages installed successfully.
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!
- 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.
- 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 …
-Name adobereader, `
- Run through Windows Update and apply all necessary updates.
- Prepare the PC for imaging.
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 …