Skip to content

Instantly share code, notes, and snippets.

@avvi00
Last active February 11, 2020 08:51
Show Gist options
  • Save avvi00/1a69b6f5eca522acf227dc2ab17e88c1 to your computer and use it in GitHub Desktop.
Save avvi00/1a69b6f5eca522acf227dc2ab17e88c1 to your computer and use it in GitHub Desktop.
Powershell script to enumerate all repos in your bitbucket account
$account = 'zzz'
$userPass = 'username:password'
$basicAuthHeader = "Basic " + [System.Convert]::ToBase64String( ([System.Text.ASCIIEncoding]::ASCII.GetBytes($userPass)))
$repo = Invoke-RestMethod "https://api.bitbucket.org/2.0/repositories/$account" -Headers @{Authorization = $basicAuthHeader}
$repos = @()
while ($repo.next) {
$repos += $repo
$repo = Invoke-RestMethod $repo.next -Headers @{Authorization = $basicAuthHeader}
}
$repos | % {
$_.values | % {
# do something with repo object here
$_.full_name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment