How to: List user Repositories and respective Stargazers on GitHub

This script and report extract all user repositories and stargazers on GitHub in the timeline

$UriUser="https://api.github.com/users/$($UserGitHub)"
$UriRepos="https://api.github.com/repos/$($UserGitHub)"
$base64Token=[System.Convert]::ToBase64String([char[]]$PAT)
$headers=@{Authorization='Basic {0}' -f $base64Token;Accept='application/vnd.github.v3.star+json'}
$Repos = @()
$pageRepos=1
do
{
$uriRepositories="$($UriUser)/repos?page=$($pageRepos)"
$RepositoriesResult=Invoke-RestMethod -Headers $headers -Uri $uriRepositories
$Repos+=$RepositoriesResult
$pageRepos++
} while ($RepositoriesResult.Count -gt 0)
$pageStargazers=1    
do
{
$uriStargazers="$($UriRepos)/$($repo.name)/stargazers? page=$($pageStargazers)"
$StargazersRepoResult=Invoke-RestMethod -Headers $headers -Uri $uriStargazers
foreach ($stargazer in $StargazersRepoResult)
{
$stargazer.user.login
}
$pageStargazers++
} while ($StargazersRepoResult.Count -gt 0)

--

--

Tech Solution Architect Manager na Accenture

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store