Skip to content

Commit 9047368

Browse files
committed
Find users not using copilot license in the org
1 parent 805c9c2 commit 9047368

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

github/github-license.ps1

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55

66

77
param (
8-
[string] [Parameter(Mandatory=$false)] $csvPath = "./.csv",
9-
[string] [Parameter(Mandatory=$false)] $csvPath2 = "./export-miljodir.csv"
8+
[string] [Parameter(Mandatory=$false)] $csvPath = "C:\Users\audun\Downloads\ghas_active_committers_miljodir_2024-11-28T0312.csv",
9+
[string] [Parameter(Mandatory=$false)] $csvPath2 = "C:\Users\audun\Downloads\export-miljodir-1732787819.csv",
10+
[string] [Parameter(Mandatory=$false)] $copilotCsvPath = "C:\Users\audun\Downloads\miljodir-seat-usage-1733728035.csv"
1011
)
1112

1213
$csv = import-csv -Path $csvPath
1314

1415
$usersCsv = import-csv -Path $csvPath2
1516

17+
$copilotCsv = import-csv -Path $copilotCsvPath
18+
1619
# Group by 'User login' and select the entry with the most recent 'Last pushed date'
1720
$latestPerUser = $csv | Group-Object 'User login' | ForEach-Object {
1821
$_.Group | Sort-Object -Property @{Expression = {[datetime]::Parse($_.'Last pushed date')}} -Descending | Select -First 1
@@ -22,12 +25,18 @@ $latestPerUser = $csv | Group-Object 'User login' | ForEach-Object {
2225
$userLogins = $latestPerUser.'User Login'
2326

2427
# Filter $csv2 where 'GitHub com login' is not in $userLogins
25-
$missingEntries = $usersCsv | Where-Object { -not ($userLogins -contains $_.'GitHub com login') }
28+
$nonPushingMembers = $usersCsv | Where-Object { -not ($userLogins -contains $_.'GitHub com login') }
2629

27-
# Output the missing entries
28-
$missingEntries | select "GitHub com login", "GitHub com saml name", "Github com name"
2930

30-
# Output the result
31-
#$latestPerUser | Select-Object 'User login', 'Organization / repository', 'Last pushed date', 'Last pushed email' | Sort-Object 'Last pushed date' | Format-Table -AutoSize
31+
Write-Host "We are paying for the following users Copilot licenses, but they have seemingly not pushed code to the Github org in the last 3 months" -ForegroundColor Red
32+
Write-Host "Please review and consider removing their license unless they are pushing code to other places which benefits the organization." -ForegroundColor Yellow
33+
$copilotUsedByOtherOrgsOnly = $copilotCsv | Where-Object { -not ($userLogins -contains $_.Login) } | Sort-Object 'Last Usage Date' | Select-Object 'Login', 'Last Usage Date', 'Last Editor Used' | Format-Table -AutoSize
34+
# Output users which are using copilot but seemingly not pushing code to the org
35+
$copilotUsedByOtherOrgsOnly
3236

33-
Write-Host "$($latestPerUser.Count) users found in CSV file"
37+
# Output the missing entries
38+
Write-Host "Found $($nonPushingMembers.Count) members which have not pushed code in the last 3 months."
39+
$nonPushingMembers | select "GitHub com login", "GitHub com saml name", "Github com name"
40+
# Output the result
41+
#Write-Host "$($latestPerUser.Count) users found commiting code in the last 3 months."
42+
#$latestPerUser | Select-Object 'User login', 'Organization / repository', 'Last pushed date', 'Last pushed email' | Sort-Object 'Last pushed date' | Format-Table -AutoSize

0 commit comments

Comments
 (0)