Created
March 9, 2023 09:17
-
-
Save punitganshani/2505b26f9d5838f48db832c85a7595f4 to your computer and use it in GitHub Desktop.
Get Repository Languages for Azure DevOps
This file contains hidden or 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
$url = "https://dev.azure.com/{org}/{project}/_apis/projectanalysis/languagemetrics" | |
$pat = "" | |
# Create header with PAT | |
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($pat)")) | |
$header = @{authorization = "Basic $token"} | |
$response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" | |
$array = @() | |
$response.repositoryLanguageAnalytics | ForEach-Object { | |
$repoName = $_.name | |
$first_language = $_.languageBreakdown[0].name | |
$array += new-object psobject -Property @{ | |
Repository = $repoName | |
Language = $first_language | |
} | |
if ($first_language -eq "Javascript") { | |
} elseif ($first_language -eq "Java") { | |
} | |
} | |
$array | Format-Table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment