Last active
February 21, 2022 21:50
-
-
Save mirontoli/b64316354171b54d1d4d76f4de763184 to your computer and use it in GitHub Desktop.
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
$auth = "apitest:j2vsnu3obx55ekwjkfdxfpljziiy27qkuku5jitsx73wvegpdpeq" | |
$bytes = [System.Text.Encoding]::ASCII.GetBytes($auth) | |
$token = [System.Convert]::ToBase64String($bytes) | |
$headers = @{ Authorization = "Basic $token" } |
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
$org = "tolle" # my sandbox Azure DevOps organization | |
$url = "https://dev.azure.com/$org/_apis/git/repositories?api-version=6.0" | |
# $projectId = "288c25f0-4bc9-4139-9337-cdbb328f1af8" | |
@("repo001", "repo002", "repo003") | ForEach-Object { | |
$name = $_ | |
$body = @" | |
{ | |
"name": "$name", | |
"project": { | |
"id": "$projectId" | |
} | |
} | |
"@ | |
Invoke-WebRequest -Uri $url -Method POST -Headers $headers -Body $body -ContentType "application/json" | |
} |
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
$org = "tolle" | |
$url = "https://dev.azure.com/$org/_apis/projects?api-version=6.0" | |
$projectCall = Invoke-WebRequest -Uri $url -Method GET -Headers $headers | |
$projects = $projectCall | ConvertFrom-Json | Select-Object -ExpandProperty value | |
$projectName = "try-api" # the current Azure DevOps project | |
$project = $projects | Where-Object { $_.name -eq $projectName } | |
$projectId = $project.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment