In a recent episode of Brent Ozar’s Office Hours, someone asked if there are any interesting forks of the First Responder Kit, on GitHub.
So I thought it would be useful to have a way to quickly check for forks and see when they were updated.
I came up with the following PowerShell function which does exactly that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
function Get-RepoForks { <# .DESCRIPTION Function to list forks for a GitHub repository .PARAMETER OrgName The name of the Organisation that ownd the repository .PARAMETER RepoName The name of the repository .EXAMPLE Get-RepoForks -OrgName 'BrentOzarULTD' -RepoName 'SQL-Server-First-Responder-Kit' Gets all the forks for SQL-Server-First-Responder-Kit, sorted by updated_at .EXAMPLE Get-RepoForks -OrgName 'BrentOzarULTD' -RepoName 'SQL-Server-First-Responder-Kit' | Select-Object -First 5 | Format-Table -AutoSize Gets 5 forks for SQL-Server-First-Responder-Kit, sorted by updated_at #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$OrgName, [Parameter(Mandatory = $true)] [string]$RepoName ) begin { } process { $forks_url = "https://api.github.com/repos/${OrgName}/${RepoName}/forks" $forks = Invoke-WebRequest -UseBasicParsing $forks_url -Headers @{"Accept" = "application/json" } $json = $forks.Content | ConvertFrom-Json $json | Select-Object full_name, private, html_url, created_at, updated_at, pushed_at | Sort-Object -Property updated_at -Descending } end { } } |
I hope someone will find it useful.
Enjoy!
0 Comments.