Skip to content

Instantly share code, notes, and snippets.

@rodmhgl rodmhgl/Get-GitTips.ps1
Last active Jun 30, 2017

Embed
What would you like to do?
Grabs a random tip from the Git-Tips Github repository
Function Get-GitTip {
<#
.SYNOPSIS
Grabs a random tip from the Git-Tips Github repository
.DESCRIPTION
Grabs a random tip from the Git-Tips Github repository
Designed to be used as part of my $profile to receive a daily tip
.PARAMETER URI
URI of the Tips.JSON file - defaults to the master branch of the git-tips repository
.EXAMPLE
Get-GitTip
.NOTES
Relies on the Git-tips repository on Github - https://github.com/git-tips/tips
#>
[cmdletbinding()]
param(
[Parameter(Position = 0, HelpMessage = "The URL to git-tips JSON file")]
[ValidateScript( {
$TipList = Invoke-WebRequest -URI $_ -Verbose -ErrorAction Stop
if ($TipList) { $true } else { Throw "Cannot Validate URI Parameter"}
})]
$URI = 'https://raw.githubusercontent.com/git-tips/tips/master/tips.json'
)
try {
$TipList | ConvertFrom-Json | Get-Random
} catch { Write-Error -Message "Unable to convert JSON - $($_)"; break}
}
Get-GitTip | Format-List
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.