Private/Get-PDKGithubFileContent.ps1
Function Get-PDKGithubFileContent { <# .SYNOPSIS Get file content of github file .PARAMETER FilePath The content path. .PARAMETER Owner Specifies the owner of the github Repository. .PARAMETER Repository Specifies the target repository name. .EXAMPLE PS C:\> Get-PDKGithubFileContent -FilePath 'Plan\DeathStar.pdf' -Owner 'dark-vador' -Repository 'Sith' .NOTES File Name : Get-PDKGithubFileContent.ps1 Author : Thomas ILLIET (contact@thomas-illiet.fr) Reference : https://developer.github.com/v3/repos/contents/ #> [CmdletBinding()] [OutputType([String])] Param( [Parameter(Mandatory=$True, Position=0)] [String]$FilePath, [Parameter(Mandatory=$True, Position=1)] [String]$Owner, [Parameter(Mandatory=$True, Position=2)] [String]$Repository ) Try { $FileObject = Get-PDKGithubFileObject @PSBoundParameters -ErrorAction Stop $ContentBase64 = $FileObject.Content return [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String($ContentBase64)) } Catch { # return error message from the function Get-PDKGithubFileObject Write-Error $_.Exception.Message } } |