Using GitHub Web Services (Part 2)

by Feb 4, 2021

In the previous tip we looked at the GitHub web service API for organizations. Now let’s check out how you can work with individual GitHub accounts.

Doug Finke has created a wonderful open-source PowerShell module called “ImportExcel” that makes working with Excel files a snap: https://github.com/dfinke/ImportExcel. His public GitHub user name is dfinke.

To find out the latest version of his works and where to download it, try this:

$username = 'dfinke'
$reponame = 'ImportExcel'
$url = "https://api.github.com/repos/$username/$reponame/releases/latest"
Invoke-RestMethod -UseBasicParsing -Uri $url | 
 Select-Object -Property tag_name, published_at, zipball_url, name

The result looks similar to this:

 
tag_name published_at         zipball_url                                                   
-------- ------------         -----------                                                   
v7.1.0   2020-03-21T00:38:13Z https://api.github.com/repos/dfinke/ImportExcel/zipball/v7.1.0
 

Note that the download URL will download the software project as it is seen on GitHub. If you just want to use his PowerShell module, choose the ready-to-use PowerShell module published to the PowerShell Gallery:

 
PS> Install-Module -Name ImportExcel -Scope CurrentUser   
 

When the module has been installed, thanks to Doug’s awesome work you can now pipe any data to Export-Excel. If you like, create an Excel sheet with the entire version history of Doug’s module:

$username = 'dfinke'
$reponame = 'ImportExcel'
$url = https://api.github.com/repos/$username/$reponame/releases

Invoke-RestMethod -UseBasicParsing -Uri $url | 

# workaround needed for any JSON web service result that
# consists of more than one dataset
ForEach-Object { $_ } |

Sort-Object -Property published_at -Descending |
Select-Object -Property published_at, Name, Url, body |
Export-Excel


Twitter This Tip! ReTweet this Tip!