PowerShell is great and with the “new” OneGet it get awesome. OneGet is a part of PowerShell v5 and it is a generic package manager. OneGet can get items from a repository, for example from Chocolatey (https://chocolatey.org/) Instead of spending a massive amount of time to explain how it works inside, lets just start playing with it. There is a couple of things you need to do to make OneGet to work with Chocolatey in build 9841.
Lets Install Zoomit, WinRAR and Notepad++!
Step 1 – Install the Chocolatey provider
Execute the following in an elevated PowerShell prompt:
#Setup the Webclient
$webclient = New-Object System.Net.WebClient
#DL and install Chocolatey
Invoke-Expression (($webclient).DownloadString('https://chocolatey.org/install.ps1'))
Step 2 – Download the updated and modified OneGet PowerShell Module
Execute the following in an elevated PowerShell prompt:
#DL and unzip the latest OneGet
$ZipFile = ‘C:\OneGet.Zip’
$webclient.DownloadFile(‘http://oneget.org/oneget.zip’,$ZipFile)
After download, unzip the zip folder and execute the RunToUnBlock.CMD inside the folder.
Step 3 – Import the updated OneGet module
Execute the following in an elevated PowerShell prompt:
Import-Module C:\Oneget.New\OneGet.psd1 -Force -Verbose
Step 4 – Get the Package Provider to verify that you have the correct version
(Currently that is 2.8.3.6)
Execute the following in an elevated PowerShell prompt:
Get-PackageProvider -Name Chocolatey -ForceBootstrap -Force
Step 5 – Find the fun stuff
Execute the following in an elevated PowerShell prompt:
Find-Package -Name WinRar,Zoomit,notepadplusplus -Provider Chocolatey
Step 6 – Install your package
Execute the following in an elevated PowerShell prompt:
Find-Package -Name WinRar,Zoomit,notepadplusplus -Provider Chocolatey | Install-Package -Force
/mike
Categories: PowerShell
Let’s get Chocolatey! First heard about this via Keith Garner, but this guide from Mike is not to be missed. Finally there is a global silent software installer that’s command line driven! Brilliant! Do not pass this read up!
:-)
Reblogged this on MDTGuy.WordPress.com and commented:
Let’s get Chocolatey! First heard about this via Keith Garner, but this guide from Mike is not to be missed. Finally there is a global silent software installer that’s command line driven! Brilliant! Do not pass this read up!
I have error when execute command
Import-Module C:\Oneget.New\OneGet.psd1 -Force -Verbose
It is something about:
Delete unmanagment elements (‘HelpInfoUri’, ‘RootModule’) and try again.
Do you know what is this?
Thank you.
Are you running on Windows Server Technical Preview Build 9841?
Hmmm after instaling Powershell 3.0 all good before some errors with Import-Module C:\Oneget\OneGet.psd1 -Force -Verbose
The blog post is about Windows Server Technical Preview – Build 9841 and that runs PowerShell 5.0
Micke,
A shortened and more powershelly version :)
Remove-Module -Name OneGet -ErrorAction SilentlyContinue
$getArchive = Join-Path $env:temp oneget.zip
Invoke-WebRequest -Uri “http://oneget.org/oneget.zip” -OutFile $getArchive
Unblock-File $getArchive
$oneGetFolder = Join-Path $env:ProgramFiles “WindowsPowershell\Modules\OneGet”
New-Item -Path $oneGetFolder -ItemType directory -Force | Out-Null
Expand-Archive -Path $getArchive -DestinationPath $oneGetFolder -Force
Import-Module -Name OneGet
Get-PackageProvider -Name Chocolatey -ForceBootstrap -Force | Out-Null
Find-Package -Name “winrar”,”beyondcompare” -Provider Chocolatey | Install-Package -Force
OneGet is getting there. Do not attempt old WMF 5.0 preview builds or even the latest github pull. Then results really vary. A couple of times they have started to rebuild/refactor code so the lastest git pull has had earlier functionality been broken (as you might expect).
and those steps work flawless in Windows Server Technical Preview 9841?
There is also an code decimal error.
Invoke-Expression (($webclient).DownloadString(‘https://chocolatey.org/install.ps1′))
Should be:
Invoke-Expression (($webclient).DownloadString(‘https://chocolatey.org/install.ps1′))
Apparently it looks good in comment field but not in blog post. :)
fixed
the problem is that wordpress modified the last part, sorry about that