Skip to content

Instantly share code, notes, and snippets.

@ljtill
Last active December 6, 2019 16:36
Show Gist options
  • Select an option

  • Save ljtill/dc4c6f508a22b2d147ac1ed9a8bd202e to your computer and use it in GitHub Desktop.

Select an option

Save ljtill/dc4c6f508a22b2d147ac1ed9a8bd202e to your computer and use it in GitHub Desktop.
Provides the ability to clone all GitHub repositories of an owner
function Invoke-GitHubRepositoriesClone {
[CmdletBinding()]
param (
[Parameter()]
[string]$PersonalAccessToken
)
begin {
$request = @{
Method = "GET"
Uri = "https://api.github.com/user/repos?affiliation=owner"
Headers = @{
"Authorization" = ("token " + $personalAccessToken)
"Accept" = "application/vnd.github.v3+json"
}
Body = $null
}
}
process {
$response = Invoke-RestMethod @request
$response | ForEach-Object {
git clone $_.git_url
}
}
end {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment