Skip to content

Add Azure DevOps sizing script#129

Open
bhaskard wants to merge 2 commits into
masterfrom
bhaskard-add-azure-devops-script
Open

Add Azure DevOps sizing script#129
bhaskard wants to merge 2 commits into
masterfrom
bhaskard-add-azure-devops-script

Conversation

@bhaskard

@bhaskard bhaskard commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Plain migration of an existing internal Azure DevOps sizing script into this repo under AZURE_DEVOPS/.
  • The script queries an Azure DevOps organisation via the REST API and reports counts of Git repos, TFVC repos, and the total Git repo size (MB).
  • Accepts organisation and a personalAccessToken (SecureString); prompts interactively when omitted. PAT requires read scope on Code.

Test plan

  • Run on a test Azure DevOps org with a read-only PAT and verify Git repo count and total size match the portal.
  • Verify TFVC repo count matches the portal; orgs without TFVC should not surface errors.
  • Confirm SecureString PAT handling does not leave plaintext in memory after execution.

Notes

  • This PR is a migration only — no functional changes vs. the source script.
  • Extending the script to also report work items, pipelines, and artifact feeds will be tracked separately after confirming scope with the script owner.

@mtellin mtellin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review - Changes Requested

Script omits the work items, pipelines, and artifact feed counts described in the PR summary; the script only collects Git and TFVC repo counts and Git sizes.

🔴 Blockers

  1. [functionality] Script body does not match PR description - AZURE_DEVOPS/Azure_Devops.ps1
    The PR summary lists five data points: Git repos, TFVC repos, work items, pipelines, and artifact feeds. The script only collects Git repos (with size) and TFVC repos. Work item counts, pipeline counts, and artifact feed counts are absent. A reviewer running the test plan step 1 against the portal would see immediately that three of the five metrics are missing.
    Fix: Add REST calls for work items (e.g. Wiql query or _apis/wit/workitems count per project), pipelines (_apis/build/definitions), and artifact feeds (_apis/packaging/feeds). Alternatively, scope the PR down to Git/TFVC only and update the description to match.

🟢 Nits

  1. [style] Missing newline at end of file - AZURE_DEVOPS/Azure_Devops.ps1:50
    PowerShell best practice and many editors expect a trailing newline.
    Fix: Add a newline after the last Write-Host line.
  2. [readability] Consider adding a -Organization alias for American-English callers - AZURE_DEVOPS/Azure_Devops.ps1:1
    Azure DevOps documentation uses "organization" (American spelling). Adding [Alias("Organization")] to the param would match the portal terminology.
    Fix: [Parameter()][Alias("Organization")][string]

✅ What's good

  • Clean SecureString → BSTR → ZeroFreeBSTR pattern correctly prevents the PAT from lingering in memory.
  • Per-project TFVC error handling with Write-Verbose is appropriate — orgs with no TFVC should not surface errors.

Dimensions reviewed: functionality, security, readability, style, performance, testing, consistency

@bhaskard

Copy link
Copy Markdown
Contributor Author

Thanks for the review @mtellin.

This PR is a plain migration of the existing internal script — I want to keep the diff equal to the source so the migration is auditable. Two follow-ups:

Blocker (work items / pipelines / artifact feeds): Updated the PR description to match the script's actual scope (Git + TFVC counts and Git size). Extending coverage to work items, pipelines, and artifact feeds is a real gap, but I'd like to confirm scope with the script owner first and track it as a separate change rather than fold it into the migration.

Nit 1 (trailing newline): Fixed in the latest commit.

Nit 2 ([Alias("Organization")]): Leaving as-is for the migration; happy to add it in the follow-up that extends functionality.

@bhaskard

Copy link
Copy Markdown
Contributor Author

@mtellin fixed as per the comments

@stevenctong

Copy link
Copy Markdown
Contributor

Approved for migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants