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:

Get-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:

Update-Help

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

Update-Help : Failed to update Help for the module(s) ‘NetworkSwitch, OneGet’ with UI culture(s) {en-US} : For
security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on
XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
At line:1 char:1
+ Update-Help
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Update-Help], Exception
+ 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.

Find-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:

Find-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:

Get-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:

Find-Package

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

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

Find-Package -Name AdobeReader, ImgBurn, WinRAR |
Install-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:

Set-ExecutionPolicy RemoteSigned

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

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

Find-Package -Name AdobeReader, ImgBurn, WinRAR |
Install-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:

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

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

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

Get-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 :-).

µ