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:

2014-04-06_15-50-52

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:

2014-04-06_15-56-05

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

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

2014-04-06_16-03-57

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.

2014-04-06_16-29-14

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:

2014-04-06_14-43-35

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:

2014-04-06_16-44-52

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

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

2014-04-06_16-50-46

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

2014-04-06_16-56-08

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:

2014-04-06_16-58-51

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

2014-04-06_17-00-10

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

2014-04-06_17-02-29

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

2014-04-06_15-39-05

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

2014-04-06_17-07-40

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

µ

3 Comments

  1. Greg Wojan

    Mike,

    ImgBurn includes the OpenCandy crapware installer. I was just wondering if you saw in junk installed on your test machine or if the silent install somehow bypasses OpenCandy? It seems the author of ImgBurn is not going to stop using OpenCandy any time soon. 🙁

    Reply

Leave a Reply

%d bloggers like this: