Skip to content

Instantly share code, notes, and snippets.

@tbvinh
Created January 29, 2026 06:56
Show Gist options
  • Select an option

  • Save tbvinh/31e38452cde4f22d09990178da679f85 to your computer and use it in GitHub Desktop.

Select an option

Save tbvinh/31e38452cde4f22d09990178da679f85 to your computer and use it in GitHub Desktop.
Tìm và xóa user trong tất cả các repositories của Github
$TEN_CUA_BAN = "tbvinh"
$XXXX = "xxx" #-- người cần xóa
# Lấy danh sách tên tất cả repo
$repos = gh repo list $TEN_CUA_BAN --limit 1000 --json name --jq '.[].name'
foreach ($repo in $repos) {
# Kiểm tra xem user có trong repo này không
$check = gh api "/repos/$TEN_CUA_BAN/$repo/collaborators/$XXXX" --silent 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "[!] Phát hiện $XXXX trong $repo. Đang tiến hành xóa..." -ForegroundColor Yellow
#gh api -X DELETE "/repos/$TEN_CUA_BAN/$repo/collaborators/$XXXX"
Write-Host "[V] Đã xóa thành công!" -ForegroundColor Green
} else {
Write-Host "[-] $XXXX không có trong repo $repo." -ForegroundColor Gray
}
}
Write-Host "--- HOÀN TẤT KIỂM TRA ---" -ForegroundColor Cyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment