Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Downloading Git Tips with PowerShell

Posted on June 27, 2016

So I've been sharing a number of PowerShell tools I've created for working with Git, including a few for getting tips from the Git Tips project on GitHub. My initial work was based on the fact that I had a local clone of that repository and wanted to search the local tips.json file. But I realized some of you may not want to clone the repository or be able to keep it up to date. Since the json file is available online and PowerShell has tools for grabbing Internet content, I decided to provide a version that combines the functionality of my earlier commands with the ease of searching online.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

PowerShell has several cmdlets you can use for getting web content. I'm using Invoke-RestMethod primarily because it will automatically convert the downloaded json data into objects.

$params = @{
     Uri = "https://raw.githubusercontent.com/git-tips/tips/master/tips.json"
     ErrorAction = "Stop"
    }
    Write-Verbose "Retrieving tips from $($params.uri)"
    $tips = Invoke-RestMethod @params

Once I've downloaded the tips I can do whatever I want. I can select a single, random tip, display them all or search the tip title. My new command offers all of these options.

Once I dot source the command into my PowerShell session (or load it in your profile) I can get all tips from the online json file which is the default behavior.

getting all online git tips with PowerShell

I can also search, including using regular expressions if I wanted.

searching git tips

Finally, I can use this function as my tip of the day by getting a random tip.

Getting a random Git tip

I even added a parameter to make it "pretty" using Write-Host.

A pretty Git tip of the day

Again, none of this requires that you have a clone of the GitHub repository or even have git installed. If have encounter any issues with the function, please post them in a comment on the Gist page.

Enjoy and hoping you have an unfor-Git-able week!


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d