Created
June 17, 2020 21:15
-
-
Save RandomNoun7/395da514380ca67da3d406b046f0b957 to your computer and use it in GitHub Desktop.
Scan Github Org For Internal Runners
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Module PowerShellForGithub | |
# Enter anything for username, and your token for the password. | |
# This sets it globally for all future runs. | |
Set-GitHubAuthentication | |
$repos = Get-GithubRepository -OrganizationName puppetlabs | |
foreach ($repo in $repos) { | |
$runner = Invoke-GHRestMethod -UriFragment "/repos/$($_.full_name)/actions/runners" -Method Get -ErrorAction SilentlyContinue | |
if($runner.runners.count -gt 0) { | |
$runner_object = [pscustomobject]@{ | |
repo = $_.full_name | |
url = $_.html_url | |
runner_id = $runner.runners[0].id | |
runner_name = $runner.runners[0].name | |
runner_status = $runner.runners[0].status | |
} | |
Write-Host $runner_object.repo, $runner_object.url, $runner_object.runner_name | |
$runner = $null | |
$runner_object | Export-Csv ~/runners.csv -Append | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment