Private/Provider/Get-ModuleProvider.ps1

function Get-ModuleProvider {
    if ($null -ne $script:ModuleProvider) {
        return $script:ModuleProvider
    }

    if (Get-Module -Name 'Microsoft.PowerShell.PSResourceGet' -ListAvailable -ErrorAction SilentlyContinue) {
        $script:ModuleProvider = 'PSResourceGet'
        return $script:ModuleProvider
    }

    if (Get-Module -Name 'PowerShellGet' -ListAvailable -ErrorAction SilentlyContinue) {
        $script:ModuleProvider = 'PowerShellGet'
        return $script:ModuleProvider
    }

    throw "No supported module provider found. Please install 'Microsoft.PowerShell.PSResourceGet' or 'PowerShellGet'."
}