Installing Software with the OneGet Module in PowerShell version 5

As referenced in my previous blog article, a preview version of PowerShell version 5 was released last week.

One of the new modules is named "OneGet" which contains a number of new PowerShell cmdlets:

1Get-Command -Module OneGet

2014-04-06_15-50-52.png

There's only limited help available for these cmdlets since attempting to update the help fails for the two new modules that are part of the PowerShell version 5 preview:

1Update-Help

2014-04-06_15-56-05.png

1Update-Help : Failed to update Help for the module(s) ‘NetworkSwitch, OneGet’ with UI culture(s) {en-US} : For
2security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on
3XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
4At line:1 char:1
5+ Update-Help
6+ ~~~~~~~~~~~
7+ CategoryInfo : InvalidData: (:) [Update-Help], Exception
8+ FullyQualifiedErrorId : HelpInfoXmlValidationFailure,Microsoft.PowerShell.Commands.UpdateHelpCommand

One of the things you can see in the help is that the Name parameter of Find-Package accepts more than one value (an array of strings):

2014-04-06_16-00-48.png

You can also see that the "Name" parameter is the only one that accepts pipeline input:

2014-04-06_16-03-57.png

What does all of that mean? It means you should be able to query the software that's installed on another machine and pipe those results to Find-Package.

Let's keep it simple for now though.

The first time you use the Find-Package cmdlet, you'll receive this prompt and it does require an Internet connection otherwise it will fail after a few minutes (without an error message). You'll receive this prompt each time you run this cmdlet until you answer yes, have an Internet connection, and allow it to install the NuGet Package Manager.

1Find-Package

2014-04-06_16-29-14.png

Pressing Ctrl+C at this prompt will break it until you exit out of PowerShell and re-open it so don't use Ctrl+C to break out of this prompt (don't ask how I know this).

If everything works properly, the necessary software will be installed:

1Find-Package

2014-04-06_14-43-35.png

I did figure out that if you run some of the other cmdlets first such as Get-Package, it will also install this software if it wasn't previously installed:

1Get-Package

2014-04-06_16-44-52.png

That only happens one time for whichever cmdlet is run first.

Be prepared to be overwhelmed if you run Find-Package without any parameters:

1Find-Package

2014-04-06_16-50-46.png

Now for the magic. I'll install Adobe Reader, ImgBurn, and WinRAR:

1Find-Package -Name AdobeReader, ImgBurn, WinRAR |
2Install-Package

2014-04-06_16-56-08.png

Oh no, that command returned the dreaded red text error message :-(. I wanted to make sure I showed you this error message since it's possible you'll run into the same issue as well. This test machine was built yesterday and is a default install so I haven't changed the script execution policy yet which caused the error.

I'll change the script execution policy to RemoteSigned:

1Set-ExecutionPolicy RemoteSigned

2014-04-06_16-58-51.png

Then give it another try. So far so good, the first package is being downloaded:

1Find-Package -Name AdobeReader, ImgBurn, WinRAR |
2Install-Package

2014-04-06_17-00-10.png

Success! You'll notice that the installations created icons on my desktop:

2014-04-06_17-02-29.png

The -Verbose parameter can be used to receive more detailed information:

1Find-Package -Name AdobeReader, ImgBurn, WinRAR |
2Install-Package -Verbose

2014-04-06_15-39-05.png

The Get-Package cmdlet can be used to see the packages that are installed:

1Get-Package

2014-04-06_17-07-40.png

Be sure to take a look at my other blog articles about the OneGet module in the preview version of PowerShell version 5 because this blog article is just the tip of the iceberg :-).

µ