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
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
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):
You can also see that the "Name" parameter is the only one that accepts pipeline input:
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
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
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
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
Now for the magic. I'll install Adobe Reader, ImgBurn, and WinRAR:
1Find-Package -Name AdobeReader, ImgBurn, WinRAR |
2Install-Package
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
Then give it another try. So far so good, the first package is being downloaded:
1Find-Package -Name AdobeReader, ImgBurn, WinRAR |
2Install-Package
Success! You'll notice that the installations created icons on my desktop:
The -Verbose parameter can be used to receive more detailed information:
1Find-Package -Name AdobeReader, ImgBurn, WinRAR |
2Install-Package -Verbose
The Get-Package
cmdlet can be used to see the packages that are installed:
1Get-Package
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 :-).
µ