Skip to content

Instantly share code, notes, and snippets.

@punitganshani
Created March 9, 2023 09:17
Show Gist options
  • Save punitganshani/2505b26f9d5838f48db832c85a7595f4 to your computer and use it in GitHub Desktop.
Save punitganshani/2505b26f9d5838f48db832c85a7595f4 to your computer and use it in GitHub Desktop.
Get Repository Languages for Azure DevOps
$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