You are here

How to Consume The Github API With PowerShell

PowerShell is a versatile and powerful command-line shell and associated scripting language developed by Microsoft on the .NET framework. It was designed to help with configuration management and task automation to quickly solve tedious and repetitive administration tasks.

As a result, PowerShell is useful for network admins for things like displaying all USB devices installed on one or multiple devices on a network, or setting time-consuming tasks to run in the background while continuing with other work.

With its hundreds of customizable commands (called cmdlets), PowerShell can help increase productivity dramatically. In this post on the Channel 9 blog, Microsoft MVP for Windows PowerShell Trevor Sullivan presents a tutorial video showing followers how to use the GitHub REST API to automate common tasks. These tasks include creating and deleting a repository, opening and closing issues, updating your user profile on GitHub, and other typical tasks.

For this platform automation, Sullivan primarily uses the Invoke-RestMethod command in the PowerShell ISE that presents a variety of parameters for invoking different REST APIs. For this tutorial, the author is looking mostly at the Method, URI, Header, and Body parameters of that command to build a JSON payload that will be inserted into the RestMethod call.

The tutorial also covers how to authenticate to GitHub using pre-generated Personal Access Tokens. Sullivan’s screencast jumps back and forth between the PowerShell ISE and GitHub, making it simple for students to follow along and automate their own GitHub tasks using Windows PowerShell.

Be sure to read the next Automation article: How to Mashup The Slackbot API with Maps and a Craiglist Scraper Using Python

Original Article

Automating the GitHub REST API Using PowerShell




Is this code available to download anywhere? Did I miss a link?


@jptoto - I don't think the original author made the code available as best I can tell.