Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
143 lines (105 sloc) 4.77 KB


Build status

PowerShell wrapper for GitHub API.

This repository currently contains two modules:

  • GitHubAnalytics.psm1 - for querying issues, pull requests, collaborators, contributors, and organizations
  • GitHubLabels.psm1 - for operations on GitHub labels

Please scroll down to the "Examples" section for details on what operations are supported.


You can get latest release of the PowerShellForGitHub on the PowerShell Gallery

Install-Module -Name PowerShellForGitHub


  1. Rename ApiTokensTemplate.psm1 to ApiTokens.psm1 and update value of $global:gitHubApiToken with GitHub token for your account
  • You can obtain it from
  • If you don't provide GitHub token, you can still use this module, but you will be limited to 60 queries per hour.
  • You will need to edit this file from an elevated context.
  1. Import module you want to use and call it's function, e.g.
Import-Module .\GitHubAnalytics.psm1
$issues = Get-GitHubIssuesForRepository -repositoryUrl @('')

Running tests

  1. Install Pester
Install-Module -Name Pester 
  1. Start test pass

Go to the Tests folder and run:


Make sure ApiTokens.psm1 exists and contains $global:gitHubApiToken with your GitHub key. Please keep in mind some tests may fail on your machine, as they test private items (e.g. secret teams) which your key won't have access to.


Contributions are welcome, please open issue on what functionality you would like to see added/contribute or simply send a pull request.



Querying issues

$issues = Get-GitHubIssuesForRepository `
-repositoryUrl @('')
$issues = Get-GitHubWeeklyIssuesForRepository `
-repositoryUrl @('',`
'') -datatype closed
$issues = Get-GitHubTopIssuesRepository `
-repositoryUrl @('',`
'', '') -state open

Querying pull requests

$pullRequests = Get-GitHubPullRequestsForRepository `
-repositoryUrl @('')
$pullRequests = Get-GitHubWeeklyPullRequestsForRepository `
-repositoryUrl @('',`
'') -datatype merged
$pullRequests = Get-GitHubTopPullRequestsRepository `
-repositoryUrl @('', '')`
-state closed -mergedOnOrAfter 2015-04-20

Querying collaborators

$collaborators = Get-GitHubRepositoryCollaborators`
-repositoryUrl @('')

Querying contributors

$contributors = Get-GitHubRepositoryContributors`
-repositoryUrl @('', '')
$contributors = Get-GitHubRepositoryContributors`
-repositoryUrl @('','')

$uniqueContributors = Get-GitHubRepositoryUniqueContributors -contributors $contributors

Quering teams / organization membership

$organizationMembers = Get-GitHubOrganizationMembers -organizationName 'OrganizationName'
$teamMembers = Get-GitHubTeamMembers -organizationName 'OrganizationName' -teamName 'TeamName'


Getting labels for given repository

$labels = Get-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName Powershell

Adding new label to the repository

New-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName PowerShell -labelName TestLabel -labelColor BBBBBB

Removing specific label from the repository

Remove-GitHubLabel -repositoryName desiredstateconfiguration -ownerName powershell -labelName TestLabel

Updating specific label with new name and color

Update-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName Powershell -labelName TestLabel -newLabelName NewTestLabel -labelColor BBBB00