Public/Get-SfApiVersions.ps1

<#
    .SYNOPSIS
    Queries salesforce for the REST API Versions

    .DESCRIPTION
    Used to query for the REST API versions

    .INPUTS
    Accepts the API name from the pipeline

    .OUTPUTS
    An array of PSCustomObject with the properties:
        Id
        phecc__ApiName__c
        phecc__ClassName__c
        phecc__Version__c

    .EXAMPLE
    PS> $versions = Get-SfApiVersions -ApiName "ScalarRest"

    .LINK
    Set-Config

    .NOTES
    Assumes config is initialized for org access.
#>

function Get-SfApiVersions {

    [CmdletBinding()]
    [OutputType([PSCustomObject[]])]
    param(
        [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline)]
        [ValidateNotNull()]
        [String]
        $ApiName
    )

    begin {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
    }

    end {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
    }

    process {
        Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

        $query = "SELECT phecc__ApiName__c,phecc__ClassName__c,phecc__Version__c FROM phecc__RestAPIVersions__c"
        if ($PSBoundParameters.ContainsKey('ApiName')) {
            $query += " WHERE phecc__ApiName__c = '$($ApiName)'"
        }
        Invoke-SfQuery $query
    }
}