• Stars
    star
    175
  • Rank 210,728 (Top 5 %)
  • Language
    PowerShell
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This PowerShell module contains commands to manage GitHub through its REST API.

PSGitHub

powershellgallery downloads build chat

PowerShell module with commands to query and manage GitHub through its REST API.

Installation

Install PSGitHub

You can install the PSGitHub PowerShell module using one of the following methods.

  1. Install from the PowerShell Gallery (requires PowerShell 5.0+)
    Install-Module PSGitHub
  2. Copy-install the module to your $env:PSModulePath
  3. Extract the module anywhere on the filesystem, and import it explicitly, using Import-Module

Setup

To access private repositories, make changes and have a higher rate limit, create a GitHub token. This token can be provided to all PSGitHub functions as a SecureString through the -Token parameter. You can set a default token to be used by changing $PSDefaultParameterValues in your profile.ps1:

On Windows

$PSDefaultParameterValues['*GitHub*:Token'] = 'YOUR_ENCRYPTED_TOKEN' | ConvertTo-SecureString

To get the value for YOUR_ENCRYPTED_TOKEN, run Read-Host -AsSecureString | ConvertFrom-SecureString once and paste in your token.

On macOS/Linux

macOS and Linux do not have access to the Windows Data Protection API, so they cannot use ConvertFrom-SecureString to generate an encrypted plaintext version of the token without a custom encryption key.

If you are not concerned about storing the token in plain text in the profile.ps1, you can set it like this:

$PSDefaultParameterValues['*GitHub*:Token'] = 'YOUR_PLAINTEXT_TOKEN' | ConvertTo-SecureString -AsPlainText -Force

Alternatively, you could store the token in a password manager or the Keychain, then retrieve it in your profile and set it the same way.

Features

Included Cmdlets

Supported Verbs GitHub Resource
Add, Get Assignee
Get CombinedCommitStatus
Get, New Comment
Start Fork
Get, New, Remove, Save, Update Gist
Remove GitRef
Find, Get, New, Update Issue
Get IssueTimeline
Find, Get, New, Remove, Update Label
Get License
Get Milestone
Get Organization
Get Project
Get, Move, New ProjectCard
Get ProjectColumn
Get, Merge, New PullRequest
Get PullRequestFile
Get RateLimit
Get, New Release
Get, New, Remove ReleaseAsset
Find, Get, New, Remove Repository
New, Submit Review
New ReviewRequest
Get Team
Get TeamMember
Set Token
Find, Get, Update User

Pretty Formatting

PSGitHub includes pretty, colored output formatting. Different views are available when piping to different Format-* cmdlets (Format-Table, Format-List, Format-Custom and Format-Wide) and specifying the -View parameter. Markdown in issue bodies and comments is highlighted as well.

Issues & Pull Requests

Format-Table (default)

Screenshot of Issue Table View

Format-Custom

Screenshot of Issue Custom View

Format-List -View Full

Includes colored labels and rendered markdown.

Screenshot of PullRequest List Full View

Milestones

Screenshot of Milestone Table View

Labels

Screenshot of Label Table View

Labels also support Format-Wide.

Commit Statuses

Screenshot of CombinedCommitStatus List View

Autocompletion

There is autocompletion for almost all parameters, namely -Owner, -RepositoryName, -Number (issue numbers), -Label, -Assignee, -MilestoneName. Search keywords in Find-Github* queries also have autocompletion.

Screenshot of issue autocompletion

Pipeline Support

All cmdlets have pipeline support. This means you can take the output of one cmdlet like Find-GitHubIssue and pipe it into another like Update-GitHubIssue.

# Close all wont-fix issues
Find-GitHubIssue "is:open label:wont-fix" | Update-GitHubIssue -State closed

PSGitHub is also designed to interoperate with PowerGit. This means for example that you can pipe a PowerGit branch object into New-GitHubPullRequest to open a new pull request from that branch (Get-GitHubPullRequest and Merge-GitHubPullRequest work equally). At the minimum, piping any PowerGit object (repository, branch, commit, remote, etc) will fill the -Owner and -RepositoryName parameters.

# Opening a new PR for a new branch
New-GitBranch my-branch | Send-GitObject | New-GitHubPullRequest

# Merging the PR of the current branch
Get-GitHead | Merge-GitHubPullRequest -WaitForStatusChecks

# Clone a GitHub repository
Get-GitHubRepository -RepositoryName foo | Copy-GitRepository

Pagination

Pagination is automatic. Every cmdlet that queries collections will keep making requests for new pages and emit objects until the end is reached. To limit the number of results, pipe to Select-Object -First.

Types

All objects returned are raw GitHub API responses, however with assigned TypeNames, which have Types.ps1xml files. They are extended with several additional properties, for example aliasing all snake_cased properties to PascalCase for consistency with PowerShell naming conventions.

Contributing

SVG Screenshots

SVG Screenshots are created with term2svg

termtosvg ./Screenshots/frames -s -g 100x12 -t base16_default_dark -c 'pwsh -NoExit -Command clear'

-s outputs still .svg frames. Always use the base16_default_dark theme for consistency. Keep the column width at 100 for best readability in the README (resize your terminal to match the width). If 12 is not enough the row height should be matched to the output of the command. Execute your command, then execute exit. Pick the frame that shows the command output but does not show the next prompt.

Issues

Please report issues in the GitHub Issue Tracker.

Contributors

This module was originally developed by Trevor Sullivan. You can contact Trevor using one of the following methods:

Core Contributors

More Repositories

1

PowerEvents

PowerEvents is a PowerShell module that assists in the registration of WMI permanent event subscriptions.
PowerShell
61
star
2

PSPuTTY

The PSPuTTY PowerShell module enables you to manipulate PuTTY sessions on Windows.
PowerShell
26
star
3

elgato

A PowerShell module to manage Elgato devices.
PowerShell
26
star
4

azure-powershell-extensions

The Azure PowerShell Extensions project is intended to provide a pleasant user experience on top of the core Azure PowerShell experience.
PowerShell
21
star
5

publish-powershell-module-action

This GitHub Action helps publish your PowerShell module to the PowerShell Gallery automatically.
PowerShell
18
star
6

youtube

A PowerShell module to manage YouTube content via the official REST API.
PowerShell
17
star
7

cADFS

This repository contains the cADFS PowerShell module, containing Desired State Configuration (DSC) resources to manage Active Directory Federation Services (ADFS).
PowerShell
14
star
8

starlink-ipv6

Configure your Ubiquiti EdgeRouter X to use IPv6 prefix delegation with SpaceX Starlink satellite internet. 🛰️📡
Shell
11
star
9

terminal

Automate the Microsoft Windows Terminal using PowerShell
PowerShell
10
star
10

elgato-streamdeck-powershell

A plug-in for Elgato Stream Deck that displays your NVIDIA GPU utilization, written in pure PowerShell
PowerShell
9
star
11

ProcessPriority

PowerShell module that sets process priority on the Windows platform
PowerShell
8
star
12

AzureADToken

A PowerShell module that allows you to get a JSON Web Token (JWT) from Azure Active Directory (AAD).
PowerShell
8
star
13

aws-systemsmanager-publicdocuments

Solution that archives publicly accessible AWS Systems Manager documents.
5
star
14

tampermonkey-youtubequality

Tampermonkey script enabling keyboard control of YouTube video quality.
JavaScript
5
star
15

PowerShell-DSC-ConfigMgr

A set of DSC Resources for Microsoft System Center 2012 Configuration Manager
PowerShell
5
star
16

awesome-trevor

This repository contains links to things that Trevor thinks are awesome.
4
star
17

PSWiFi

A PowerShell module to manage WiFi connections on the Windows platform.
PowerShell
3
star
18

oscon-2017

This repository contains the content for PowerShell: The Future of Automation on Linux
PowerShell
3
star
19

influxdb-v2-arm

Run InfluxDB v2 on 64-bit ARM devices, such as the Raspberry Pi
Dockerfile
2
star
20

Secunia-Webinar-ConfigMgr-Azure-Lab

PowerShell code to create a Microsoft System Center 2012 R2 Configuration Manager lab environment in Microsoft Azure.
PowerShell
2
star
21

bible-powershell

The King James Version (KJV) Bible provided as a PowerShell module.
PowerShell
2
star
22

pcgeek86

Trevor's GitHub profile.
2
star
23

userscripts

A repository containing useful browser user scripts that I've written
JavaScript
2
star
24

PSNuGet

A PowerShell module to assist with creating and managing NuGet packages.
PowerShell
2
star
25

PowerShell-Azure-Media-Services

This project offers Azure Media Services automation capabilities that are missing from the core Azure PowerShell module.
PowerShell
2
star
26

microsoft-terminal-color-schemes

A huge list of color schemes for Microsoft Terminal
1
star
27

ansible

A repository containing a useful Ansible configuration for an Ubuntu Linux VM.
1
star
28

katacoda-scenarios

Interactive software training tutorials on Katacoda
1
star
29

tick-stack-arm

InfluxData TICK stack for ARM devices
1
star
30

blender-addon-gotoframe

Adds a custom Blender command to go to a specific frame on the animation timeline.
Python
1
star
31

pcgeek86.github.io

Trevor's master GitHub project page.
HTML
1
star
32

kotlin-docker

A Docker image build containing a development environment for Kotlin
Shell
1
star
33

epsolar-tracer-influxdb

Write metrics from solar ☀ charge controller to InfluxDB Cloud 📈
Python
1
star