$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'

$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h

# VGs por MS
$msNames = @('ms-auth-external','ms-auth-sso','ms-barramento','ms-belt','ms-notify','ms-parameters','ms-person','ms-poc','ms-user')

Write-Host "=== Variable Groups por MS (dev) ===" -ForegroundColor Cyan
foreach ($ms in $msNames) {
  $vgName = "$ms-dev"
  $vg = $vgs.value | Where-Object { $_.name -eq $vgName }
  if (-not $vg) {
    Write-Host "  $vgName : NAO ENCONTRADO" -ForegroundColor Red
    continue
  }
  $vars = $vg.variables.PSObject.Properties | Select-Object -ExpandProperty Name
  Write-Host "  $vgName : $($vars -join ', ')" -ForegroundColor Green
}

Write-Host ""
Write-Host "=== Verificando ms-auth-external-dev em detalhe ===" -ForegroundColor Cyan
$vgDetail = $vgs.value | Where-Object { $_.name -eq 'ms-auth-external-dev' }
if ($vgDetail) {
  $vgDetail.variables.PSObject.Properties | ForEach-Object {
    $val = if ($_.Value.isSecret) { '(secret)' } else { $_.Value.value }
    Write-Host "  $($_.Name) = $val"
  }
}
