Last active
June 30, 2017 22:14
-
-
Save rodmhgl/300484237371686c94ad76a4e82cb911 to your computer and use it in GitHub Desktop.
Grabs a random tip from the Git-Tips Github repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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