After playing with OneGet and PowerShellGet for some time now I wanted to dive into the OData feed that both new PowerShell v5 preview features are using.

Let me first summarize OneGet and PowerShellGet.

OneGet is a new way to discover and install software packages from around the web. With OneGet, you can:

  • ·Manage a list of software repositories in which packages can be searched, acquired, and installed
  • · Search and filter your repositories to find the packages you need
  • · Seamlessly install and uninstall packages from one or more repositories with a single PowerShell command

This first version of OneGet installs and searches software from Chocolatey repositories.  Support of additional repositories will come in subsequent versions.

PowerShellGet is a new way to discover, install, and update PowerShell Modules.  New in WMF 5.0 Preview May 2014, PowerShellGet contains a set of cmdlets that enable users to interact with an online module gallery.Instead of having to search through CodePlex, GitHub, various blogs, and TechNet Script Center for all the PowerShell Modules you want, you can use Find-Module to search through an online Gallery

Both use an OData feed, Open Data Protocol (OData) is a data access protocol initially defined by Microsoft. The protocol was designed to provide standard CRUD access to a data source via a website. If you want to learn more about OData just go to wikipedia.

Now we know, we can access the OneGet and PowerShellGet repositories using an OData feed we can use the PowerShell OData Explorer. With the 'OData Explorer' PowerShell application we can browse the OData Services. After downloading and unzipping the OData Explorer we need to add the two OData Services from OneGet and PowerShellGet in the ODataServices.csv file.

PowerShell OData Explorer

image

image

Name, uri
NetFlix,    "http://odata.netflix.com/Catalog"
Northwind,  "http://services.odata.org/Northwind/Northwind.svc/"
TechEd2010, "http://odata.msteched.com/sessions.svc/"
WorldCup,   "http://www.openligadb.de/Webservices/OData.svc/"
StackOverflow, "http://odata.stackexchange.com/stackoverflow/atom"
SuperUser, "http://odata.stackexchange.com/superuser/atom"
ServerFault, "http://odata.stackexchange.com/serverfault/atom"
"Meta StackOverflow", "http://odata.stackexchange.com/meta/atom"
Locations, "http://ogdi.cloudapp.net/v1/dc"
Chocolatey, "http://chocolatey.org/api/v2/"
Nuget, "http://www.nuget.org/api/v2/"
PowerShellget, "https://msconfiggallery.cloudapp.net/api/v2/"

Open the .\View-OData.ps1 PowerShell script and start browsing.

image

You can browse the Chocolatey or NuGet OData feed for the OneGet Packages or for the PowerShell Modules you can browse the PowerShelGet OData feed.

image

After browsing through the OneGet and PowerShellGet OData repositories would not it be cool if we can “just” navigate those OData feeds like we do with our other PowerShell Providers?

OData PowerShell provider

This can be done using the PowerShell OData Provider Module. The OData PowerShell provider allows you to mount OData feeds as drives in your powershell session. This enables simple and intuitive access to the catalogs, collections, and entities in the feed using the same cmdlets you use for working with files. Download, unzip and install the PowerShell OData Provider and get started navigating your OneGet and PowerShellGet OData feed just like any other PowerShell Provider.

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
import-module OData

#Get-Help on OData queries
get-help about_OData_Query

#Create an new OneGet Drive
New-PSDrive -Name OneGet -PSProvider OData -Root "http://chocolatey.org/api/v2/"

#Go to OneGet Drive
cd OneGet

#Search for latest 7zip package
get-childitem OneGet:/packages -orderby Version -filter "Title eq '7zip'" -top 1

#Create an new PowerShelGet Drive
New-PSDrive -Name PowerShellGet -PSProvider OData -Root "https://msconfiggallery.cloudapp.net/api/v2/"

#Search top PowerShell Module downloads from PowerShellGet Repository
get-childitem PowerShellGet:/packages | 
   
where-object {$_.Islatestversion -eq "$true"} | 
   
select-object name, @{Label="Downloads";Expression= {[int]$_.Downloadcount}}| sort Downloads -Descending

image

Have fun browsing those PowerShellGet and OneGet OData feeds using the PowerShell OData Provider Module.