Skip to content

Instantly share code, notes, and snippets.

@toburger
Created January 9, 2013 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toburger/4493889 to your computer and use it in GitHub Desktop.
Save toburger/4493889 to your computer and use it in GitHub Desktop.
Gets the content of a gist which you can then save as a file: .\Get-GistFile.ps1 gist_id > filename.ext
param([Parameter(Mandatory)]$Id)
$response = Invoke-WebRequest https://api.github.com/gists/$Id
$gist = $response.Content | ConvertFrom-Json
$gist.files | gm -MemberType NoteProperty | select -First 1 | % {
$file = $gist.files."$($_.Name)"
$file.content
Write-Verbose "filename: $($file.filename)"
Write-Verbose "language: $($file.language)"
Write-Verbose "size: $($file.size)"
}
Write-Verbose "created: $([DateTime]$gist.created_at)"
Write-Verbose "updated: $([DateTime]$gist.updated_at)"
Write-Verbose "public: $($gist.public)"
Write-Verbose "url: $($gist.html_url)"
Write-Verbose "comments: $($gist.comments)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment