- Logging
- Telemetry
- Examples
All commands will log to the console, as well as to a log file, by default.
The logging is affected by configuration properties (which can be checked with
Get-GitHubConfiguration
and changed with Set-GitHubConfiguration
).
LogPath
[string] The logfile. Defaults to
$env:USERPROFILE\Documents\PowerShellForGitHub.log
DisableLogging
[bool] Defaults to $false
.
LogTimeAsUtc
[bool] Defaults to $false
. If $false
, times are logged in local time.
When $true
, times are logged using UTC (and those timestamps will end with a Z per the
W3C standard)
LogProcessId
[bool] Defaults to $false
. If $true
, the
Process ID ($global:PID
) of the current PowerShell process will be added
to every log entry. This can be helpful if you have situations where
multiple instances of this module run concurrently and you want to
more easily isolate the log entries for one process. An alternative
solution would be to use Set-GitHubConfiguration -LogPath <path> -SessionOnly
to specify a
different log file for each PowerShell process. An easy way to view the filtered
entries for a session is (replacing PID
with the PID that you are interested in):
Get-Content -Path <logPath> -Encoding UTF8 | Where { $_ -like '*[[]PID[]]*' }
In order to track usage, gauge performance and identify areas for improvement, telemetry is employed during execution of commands within this module (via Application Insights). For more information, refer to the Privacy Policy.
You may notice some needed assemblies for communicating with Application Insights being downloaded on first run of a command within each PowerShell session. The automatic dependency downloads section of the setup documentation describes how you can avoid having to always re-download the telemetry assemblies in the future.
We recommend that you always leave the telemetry feature enabled, but a situation may arise where it must be disabled for some reason. In this scenario, you can disable telemetry by calling:
Set-GitHubConfiguration -DisableTelemetry -SessionOnly
The effect of that value will last for the duration of your session (until you close your
console window). To make that change permanent, remove -SessionOnly
from that call.
The following type of information is collected:
- Every major command executed (to gauge usefulness of the various commands)
- Types of parameters used with the command
- Error codes / information
The following information is also collected, but the reported information is only reported in the form of an SHA512 Hash (to protect PII (personal identifiable information)):
- Username
- OwnerName
- RepositoryName
- OrganizationName
The hashing of the above items can be disabled (meaning that the plaint-text data will be reported instead of the hash of the data) by setting
Set-GitHubConfiguration -DisablePiiProtection -SessionOnly
Similar to DisableTelemetry
, the effect of this value will only last for the duration of
your session (until you close your console window), unless you call it without -SessionOnly
.
The first time telemetry is tracked in a new PowerShell session, a reminder message will be displayed to the user. To suppress this reminder in the future, call:
Set-GitHubConfiguration -SuppressTelemetryReminder
Finally, the Application Insights Key that the telemetry is reported to is exposed as
Get-GitHubConfiguration -Name ApplicationInsightsKey
It is requested that you do not change this value, otherwise the telemetry will not be reported to us for analysis. We expose it here for complete transparency.
# Getting all of the issues from the PowerShell\xPSDesiredStateConfiguration repository
$issues = Get-GitHubIssue -OwnerName PowerShell -RepositoryName 'xPSDesiredStateConfiguration'
# An example of accomplishing what Get-GitHubIssueForRepository (from v0.1.0) used to do.
# Get all of the issues from multiple repos, but only return back the ones that were created within
# past two weeks.
$repos = @('https://github.com/powershell/xpsdesiredstateconfiguration', 'https://github.com/powershell/xactivedirectory')
$issues = @()
$repos | ForEach-Object { $issues += Get-GitHubIssue -Uri $_ }
$issues | Where-Object { $_.created_at -gt (Get-Date).AddDays(-14) }
# An example of accomplishing what Get-GitHubWeeklyIssueForRepository (from v0.1.0) used to do.
# Get all of the issues from multiple repos, and group them by the week in which they were created.
$repos = @('https://github.com/powershell/xpsdesiredstateconfiguration', 'https://github.com/powershell/xactivedirectory')
$issues = @()
$repos | ForEach-Object { $issues += Get-GitHubIssue -Uri $_ }
$issues | Group-GitHubIssue -Weeks 12 -DateType Created
# An example of accomplishing what Get-GitHubTopIssueRepository (from v0.1.0) used to do.
# Get all of the issues from multiple repos, and sort the repos by the number issues that they have.
$repos = @('https://github.com/powershell/xpsdesiredstateconfiguration', 'https://github.com/powershell/xactivedirectory')
$issueCounts = @()
$issueSearchParams = @{
'State' = 'open'
}
$repos | ForEach-Object { $issueCounts += ([PSCustomObject]@{ 'Uri' = $_; 'Count' = (Get-GitHubIssue -Uri $_ @issueSearchParams).Count }) }
$issueCounts | Sort-Object -Property Count -Descending
# Getting all of the pull requests from the Microsoft\PowerShellForGitHub repository
$issues = Get-GitHubIssue -OwnerName Microsoft -RepositoryName 'PowerShellForGitHub'
# An example of accomplishing what Get-GitHubPullRequestForRepository (from v0.1.0) used to do.
# Get all of the pull requests from multiple repos, but only return back the ones that were created
# within the past two weeks.
$repos = @('https://github.com/powershell/xpsdesiredstateconfiguration', 'https://github.com/powershell/xactivedirectory')
$pullRequests = @()
$repos | ForEach-Object { $pullRequests += Get-GitHubPullRequest -Uri $_ }
$pullRequests | Where-Object { $_.created_at -gt (Get-Date).AddDays(-14) }
# An example of accomplishing what Get-GitHubWeeklyPullRequestForRepository (from v0.1.0) used to do.
# Get all of the pull requests from multiple repos, and group them by the week in which they were merged.
$repos = @('https://github.com/powershell/xpsdesiredstateconfiguration', 'https://github.com/powershell/xactivedirectory')
$pullRequests = @()
$repos | ForEach-Object { $pullRequests += Get-GitHubPullRequest -Uri $_ }
$pullRequests | Group-GitHubPullRequest -Weeks 12 -DateType Merged
# An example of accomplishing what Get-GitHubTopPullRequestRepository (from v0.1.0) used to do.
# Get all of the pull requests from multiple repos, and sort the repos by the number
# of closed pull requests that they have had within the past two weeks.
$repos = @('https://github.com/powershell/xpsdesiredstateconfiguration', 'https://github.com/powershell/xactivedirectory')
$pullRequestCounts = @()
$pullRequestSearchParams = @{
'State' = 'closed'
}
$repos |
ForEach-Object {
$pullRequestCounts += ([PSCustomObject]@{
'Uri' = $_;
'Count' = (
(Get-GitHubPullRequest -Uri $_ @pullRequestSearchParams) |
Where-Object { $_.completed_at -gt (Get-Date).AddDays(-14) }
).Count
}) }
$pullRequestCounts | Sort-Object -Property Count -Descending
$collaborators = Get-GitHubRepositoryCollaborators`
-Uri @('https://github.com/PowerShell/DscResources')
# Getting all of the contributors for a single repository
$contributors = Get-GitHubRepositoryContributor -OwnerName 'PowerShell' -RepositoryName 'PowerShellForGitHub' }
# An example of accomplishing what Get-GitHubRepositoryContributors (from v0.1.0) used to do.
# Getting all of the contributors for a set of repositories
$repos = @('https://github.com/PowerShell/DscResources', 'https://github.com/PowerShell/xWebAdministration')
$contributors = @()
$repos | ForEach-Object { $contributors += Get-GitHubRepositoryContributor -Uri $_ }
# An example of accomplishing what Get-GitHubRepositoryUniqueContributor (from v0.1.0) used to do.
# Getting the unique set of contributors from the previous results of Get-GitHubRepositoryContributor
Get-GitHubRepositoryContributor -OwnerName 'PowerShell' -RepositoryName 'PowerShellForGitHub' } |
Select-Object -ExpandProperty author |
Select-Object -ExpandProperty login -Unique
Sort-Object
$organizationMembers = Get-GitHubOrganizationMembers -OrganizationName 'OrganizationName'
$teamMembers = Get-GitHubTeamMembers -OrganizationName 'OrganizationName' -TeamName 'TeamName'
$labels = Get-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration
$labels = Get-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -Issue 1
$labels = Get-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -Milestone 1
New-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -Name TestLabel -Color BBBBBB
Remove-GitHubLabel -OwnerName PowerShell -RepositoryName desiredstateconfiguration -Name TestLabel
$labelNames = @{'bug', 'discussion')
Add-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue 1 -LabelName $labelNames
Remove-GitHubIssueLabel -OwnerName Microsoft -RepositoryName desiredstateconfiguration -Name TestLabel -Issue 1
Update-GitHubLabel -OwnerName Microsoft -RepositoryName DesiredStateConfiguration -Name TestLabel -NewName NewTestLabel -Color BBBB00
$labels = @( @{ 'name' = 'Label1'; 'color' = 'BBBB00'; 'description' = 'My label description' }, @{ 'name' = 'Label2'; 'color' = 'FF00000' })
Set-GitHubLabel -OwnerName PowerShell -RepositoryName DesiredStateConfiguration -Label $labels
Get-GitHubUser -Current
Update-GitHubCurrentUser -Location 'Seattle, WA' -Hireable:$false
Get-GitHubUser -Name octocat
Get-GitHubUser
Warning: This will take a while. It's getting every GitHub user.
Get-GitHubRepositoryFork -OwnerName Microsoft -RepositoryName PowerShellForGitHub
New-GitHubRepositoryForm -OwnerName Microsoft -RepositoryName PowerShellForGitHub
Get-GitHubReferrerTraffic -OwnerName Microsoft -RepositoryName PowerShellForGitHub
Get-GitHubPathTraffic -OwnerName Microsoft -RepositoryName PowerShellForGitHub
Get-GitHubViewTraffic -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Per Week
Get-GitHubCloneTraffic -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Per Day
Get-GitHubAsignee -OwnerName Microsoft -RepositoryName PowerShellForGitHub
$HasPermission = Test-GitHubAssignee -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Assignee "LoginID123"
New-GithubAssignee -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Assignees $assignees -Issue 1
Remove-GithubAssignee -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Assignees $assignees -Issue 1
Get-GitHubIssueComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Issue 1
Get-GitHubRepositoryComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Sort Created -Direction Ascending -Since '2011-04-14T16:00:49Z'
Get-GitHubComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -CommentID 1
New-GitHubComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Issue 1 -Body "Testing this API"
Set-GitHubComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -CommentID 1 -Body "Testing this API"
Remove-GitHubComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -CommentID 1
Get-GitHubMilestone -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Sort DueOn -Direction Ascending -DueOn '2011-04-14T16:00:49Z'
Get-GitHubMilestone -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Milestone 1
New-GitHubMilestone -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Title "Testing this API"
Update-GitHubIssue -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Issue 2 -Milestone 1
Set-GitHubMilestone -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Milestone 1 -Title "Testing this API edited"
Remove-GitHubMilestone -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Milestone 1
Get-GitHubEvent -OwnerName Microsoft -RepositoryName PowerShellForGitHub
Get-GitHubEvent -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Issue 1
Get-GitHubEvent -OwnerName Microsoft -RepositoryName PowerShellForGitHub -EventID 1
@LazyWinAdmin used this module to migrate his blog comments from Disqus to GitHub Issues. See blog post for full details.
# Create an issue
$IssueObject = New-GitHubIssue @githubsplat -Title $IssueTitle -Body $body -Label 'blog comments'
# Create Comment
New-GitHubComment @githubsplat -Issue $IssueObject.number -Body $CommentBody
# Close issue
Update-GitHubIssue @githubsplat -Issue $IssueObject.number -State Closed