Created
October 9, 2023 20:41
-
-
Save AfroThundr3007730/d96e402653ab1786d1bcb2ac71df4630 to your computer and use it in GitHub Desktop.
Gets a list of repositories of a GitHub user
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-GHRepoList { | |
<# .SYNOPSIS | |
Gets a list of repositories of a GitHub user. #> | |
Param( | |
# User to enumerate | |
[string]$User, | |
# Page size to request | |
[int]$Size = 100 | |
) | |
$page = 0 | |
$count = (Invoke-RestMethod -Uri ('https://api.github.com/users/{0:s}' -f $User)).public_repos | |
do { | |
$page++ | |
(Invoke-RestMethod -Uri ('https://api.github.com/users/{0:s}/repos?page={1:d}&per_page={2:d}' -f $User, $page, $Size)).html_url | |
Start-Sleep -Seconds 1 | |
} while ($page * $size -lt $count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment