In today’s data-driven world, having insights into the usage and performance of tools like GitHub Copilot is crucial for organizations. This blog post will walk you through a PowerShell script designed to fetch and report metrics from GitHub Copilot. The script automates the process of collecting data, generating reports, and handling errors, making it easier for administrators to monitor and analyze Copilot usage.
Prerequisites for this Solution:
Download the script from Git or PowerShell gallery from below links:
Git:
https://github.com/VikasSukhija/Downloads
githubcopilotmetrics.ps1
PowerShell Gallery:
https://www.powershellgallery.com/packages/githubcopilotmetrics
Install-Script -Name githubcopilotmetrics
Update the below section of the script with your own parameters:

Note: Assumption is you have already created the token for generating github copilot metrics follwoing the previous blog post – https://techwizard.cloud/2024/12/10/generate-github-copilot-usage-reports-with-api/
The Invoke-GitHubApi function inside the script is responsible for making API requests to GitHub and fetching the required data. It handles pagination to ensure all results are retrieved.
The script processes the fetched data to generate user and usage reports. It uses ForEach-Object to iterate over the data and create custom objects for each record. The reports are then exported to CSV files. (It compares each object with Active Directory to find the existence)
$Login = ($Login -replace ‘-‘, ‘.’ -replace ‘_’, ‘@’ -replace ‘testcb’, ‘test.com’)
Login information in github copilot is not exact as user’s userprincipalname so above formula is used to match the organizational address. In you case this can be a different formula.
When you run the script below reports are generated and placed in archive folder.
Languages and Suggestions report are generated day wise so as to preserve the data for longer period.

API only provides data for 30 days but using this script to you retain data as per your requirement and then show in power BI report.
I hope this solution will assist you in creating the gitub copilot metrics.
Thanks for reading and downloading…
Tech Wizard