Private/Test-PDKGithubCredential.ps1

Function Test-PDKGithubCredential {
    <#
    .SYNOPSIS
        Test Github Credential
    .EXAMPLE
        PS C:\> Test-PDKGithubCredential
    .NOTES
        File Name : Test-PDKGithubCredential.ps1
        Author : Thomas ILLIET (contact@thomas-illiet.fr)
    #>

    if(([string]::IsNullOrEmpty($Script:GithubAuthorization)) -eq $False) {

        # Set request Parameters
        $Params = @{
            Headers = @{Authorization=$Script:GithubAuthorization}
            Uri     = "https://api.github.com/user"
        }

        # Get Content Object
        try {
            [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
            $AuthorizationRequest = Invoke-RestMethod @Params -ErrorAction Stop
            if($AuthorizationRequest.id) {
                return $True
            } else {
                return $False
            }
        } Catch {
            return $False
        }

    } else {
        Write-Error "Unable to find Github Credential, please define your access with the following command 'Set-PDKGithubCredential'"
    }
}