Skip to content

Get GitHubContent

Howard Wolosky edited this page Oct 5, 2020 · 1 revision

Get-GitHubContent

SYNOPSIS

Retrieve the contents of a file or directory in a repository on GitHub.

SYNTAX

Elements (Default)

Get-GitHubContent -OwnerName <String> -RepositoryName <String> [-Path <String>] [-BranchName <String>]
 [-MediaType <String>] [-ResultAsString] [-AccessToken <String>] [<CommonParameters>]

Uri

Get-GitHubContent -Uri <String> [-Path <String>] [-BranchName <String>] [-MediaType <String>] [-ResultAsString]
 [-AccessToken <String>] [<CommonParameters>]

DESCRIPTION

Retrieve content from files on GitHub. The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub

EXAMPLES

EXAMPLE 1

Get-GitHubContent -OwnerName microsoft -RepositoryName PowerShellForGitHub -Path README.md -MediaType Html

Get the Html output for the README.md file

EXAMPLE 2

Get-GitHubContent -OwnerName microsoft -RepositoryName PowerShellForGitHub -Path LICENSE

Get the Binary file output for the LICENSE file

EXAMPLE 3

Get-GitHubContent -OwnerName microsoft -RepositoryName PowerShellForGitHub -Path Tests

List the files within the "Tests" path of the repository

EXAMPLE 4

$repo = Get-GitHubRepository -OwnerName microsoft -RepositoryName PowerShellForGitHub
$repo | Get-GitHubContent -Path Tests

List the files within the "Tests" path of the repository

PARAMETERS

-AccessToken

If provided, this will be used as the AccessToken for authentication with the REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BranchName

The branch, or defaults to the default branch of not specified.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MediaType

The format in which the API will return the body of the issue.

Object - Return a json object representation a file or folder. This is the default if you do not pass any specific media type. Raw - Return the raw contents of a file. Html - For markup files such as Markdown or AsciiDoc, you can retrieve the rendered HTML using the Html media type.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: Object
Accept pipeline input: False
Accept wildcard characters: False

-OwnerName

Owner of the repository. If not supplied here, the DefaultOwnerName configuration property value will be used.

Type: System.String
Parameter Sets: Elements
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Path

The file path for which to retrieve contents

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RepositoryName

Name of the repository. If not supplied here, the DefaultRepositoryName configuration property value will be used.

Type: System.String
Parameter Sets: Elements
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ResultAsString

If this switch is specified and the MediaType is either Raw or Html then the resulting bytes will be decoded the result will be returned as a string instead of bytes. If the MediaType is Object, then an additional property on the object named 'contentAsString' will be included and its value will be the decoded base64 result as a string.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Uri

Uri for the repository. The OwnerName and RepositoryName will be extracted from here instead of needing to provide them individually.

Type: System.String
Parameter Sets: Uri
Aliases: RepositoryUrl

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

GitHub.Branch

GitHub.Content

GitHub.Event

GitHub.Issue

GitHub.IssueComment

GitHub.Label

GitHub.Milestone

GitHub.PullRequest

GitHub.Project

GitHub.ProjectCard

GitHub.ProjectColumn

GitHub.Reaction

GitHub.Release

GitHub.ReleaseAsset

GitHub.Repository

OUTPUTS

[String]

GitHub.Content

NOTES

Unable to specify Path as ValueFromPipeline because a Repository object may be incorrectly coerced into a string used for Path, thus confusing things.

RELATED LINKS

PowerShellForGitHub

Docs

PowerShellForGitHub

Functions

Clone this wiki locally