PowerShell

PowerShell is King – Using OneGet Package Manager on Windows Server Technical Preview build 9841

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'))

 

image

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)

image

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

image

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

image

Step 5 – Find the fun stuff

Execute the following in an elevated PowerShell prompt:

Find-Package -Name WinRar,Zoomit,notepadplusplus -Provider Chocolatey

image

Step 6 – Install your package

Execute the following in an elevated PowerShell prompt:

Find-Package -Name WinRar,Zoomit,notepadplusplus -Provider Chocolatey | Install-Package -Force

image

/mike

Categories: PowerShell

Tagged as:

13 replies »

  1. 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!

  2. 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!

  3. 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.

  4. Hmmm after instaling Powershell 3.0 all good before some errors with Import-Module C:\Oneget\OneGet.psd1 -Force -Verbose

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

  6. 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′))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.