Public/Get-PSModuleVersion.ps1

function Get-PSModuleVersion {
    <#
    .SYNOPSIS
    Gets all available versions of a module from the Gallery.
    .DESCRIPTION
    Queries the specified repository for all available versions of the named module
    and returns them sorted newest first.
    .PARAMETER Name
    The module name.
    .PARAMETER Repository
    The repository. Default is PSGallery.
    .EXAMPLE
    Get-PSModuleVersion -Name "Pester"
    #>

    [CmdletBinding()]
    [OutputType([string[]])]
    param(
        [Parameter(Mandatory, Position = 0)]
        [ValidateNotNullOrEmpty()]
        [string]$Name,

        [string]$Repository = 'PSGallery'
    )

    $result = Invoke-ProviderGetVersions -Name $Name -Repository $Repository
    if (-not $result) {
        return
    }
    $result
}