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

Friday Fun: Find a Git Tip with PowerShell

Posted on June 24, 2016

Recently I published a PowerShell function that I use to display a random Git Tip of the Day. The function relies on my clone of the Git-Tips project on GitHub. I've been keeping tabs on this project and a question was posed about creating a command line utility to search the tip list. Now, this project is most likely aimed at developers, at least based on what I've seen in the list of questions and issues. But for PowerShell people, this is a pretty simple thing to pull together.

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!

I already have a local clone of the project which includes a json file. As in my Show-GitTip script, I know I can use ConvertFrom-Json to turn the json file into a objects. The object has a title property so it wouldn't be that difficult to use Where-Object to filter on a word. So I quickly put together a new function I call Find-GitTip.

Most of the function should be easy to follow. The only thing I changed was to explicitly turn each converted json object into a PSCustomObject.  When I piped to ConvertFrom-Json PowerShell was giving my an object of type System.Object[] and Where-Object wasn't filtering on the title. I probably could have adjusted the Where-Object expression but opted for the current solution. By the way I discovered all of this by piping results to Get-Member. This is a tip I always recommend: if you aren't getting the results you expect, backup and pipe to Get-Member to see exactly what PowerShell is writing to the pipeline.

The function will search for any text in the tip title:

finding a git tip with PowerShell

You can also use regular expressions.

finding a git tip with regex

My script file that defines the function also defines an alias which of course you can change.

I hope you'll let me know what you think. If you run into any problems, please post them on the Gist page for this script.

Enjoy!


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

3 thoughts on “Friday Fun: Find a Git Tip with PowerShell”

  1. Paul H Cassidy says:
    June 26, 2016 at 9:45 pm

    I am wondering why you don’t grab the tips.json file from the web to ensure you have the latest copy

    1. Jeffery Hicks says:
      June 27, 2016 at 9:37 am

      I wondered when someone would notice! Personally, I already have a local clone so it was easier, faster and works when I am on an airplane. But I have something lined up for this very task. Stay tuned.

  2. Jeffery Hicks says:
    June 27, 2016 at 10:40 am

    Here’s the online version: http://bit.ly/28VPwds

Comments are closed.

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