Last active
February 11, 2020 08:51
-
-
Save avvi00/1a69b6f5eca522acf227dc2ab17e88c1 to your computer and use it in GitHub Desktop.
Powershell script to enumerate all repos in your bitbucket account
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
$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