Private/Get-InstalledModuleForAzureToken.ps1

<#
.SYNOPSIS
    Investigate if module for connect Azure is installed and return version.
.DESCRIPTION
    Investigate if module for connect Azure is installed and return version.
.EXAMPLE
    $TypeOfModuleToConnectIntoAzure = Get-InstalledModuleForAzureToken
#>

function Get-InstalledModuleForAzureToken {
[CmdLetBinding()]
[Outputtype("String")]
param ()
    $ErrorActionPreference = 'Stop'
    Write-Debug '-- begin - Test-IsPossibleGetCredentialFromProfile --'
    $toReturn = 'none'
    $IsAzInstalled = Get-Module -Name Az.Accounts
    if(![String]::IsNullOrEmpty($IsAzInstalled)) {
        $toReturn = 'Az'
    }
    $IsAzInstalled = Get-Module -Name AzureRm.Profile
    if(![String]::IsNullOrEmpty($IsAzInstalled)) {
        if(![String]::IsNullOrEmpty($IsAzInstalled.Version) `
        -and ![String]::IsNullOrEmpty($IsAzInstalled.Version.Major) `
        -and $IsAzInstalled.Version.Major -ge 3) {
            $toReturn = 'Rm3'
        } else {
            $toReturn = 'RmOld' 
        }
    }

    Write-Debug '-- end - Test-IsPossibleGetCredentialFromProfile --'
    return $toReturn
}