Last active
December 6, 2019 16:31
-
-
Save ljtill/17eb1e501137c9e607e68e15690358c3 to your computer and use it in GitHub Desktop.
Provides the ability to clone all Azure DevOps repositories
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 Invoke-AzureDevOpsRepositoriesClone { | |
[CmdletBinding()] | |
param ( | |
[Parameter()] | |
[string]$AccountName, | |
[Parameter()] | |
[string]$ProjectName, | |
[Parameter()] | |
[string]$Username, | |
[Parameter()] | |
[string]$PersonalAccessToken | |
) | |
begin { | |
$apiVersion = "4.1" | |
$request = @{ | |
Method = "GET" | |
Uri = ("https://" + $accountName + ".visualstudio.com/" + $projectName + "/_apis/git/repositories?api-version=" + $apiVersion) | |
Headers = @{ | |
"Authorization" = ("Basic " + ([Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $personalAccessToken))))) | |
"Accept" = "application/json" | |
} | |
Body = $null | |
} | |
} | |
process { | |
$response = Invoke-RestMethod @request | |
$response.value | ForEach-Object { | |
git clone $_.remoteUrl | |
} | |
} | |
end { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment