Private/Test-IsRmConnected.ps1
<#
.SYNOPSIS Test if the AzureRm.Profile v3.0 or later is already connected to Azure .DESCRIPTION Test if the AzureRm.Profile v3.0 or later is already connected to Azure #> function Test-IsRmConnected{ [CmdLetBinding()] [Outputtype("Boolean")] $ErrorActionPreference = 'Stop' Write-Debug '-- begin - Test-IsRmConnected --' if (-not (Get-Module AzureRm.Profile)) { Import-Module AzureRm.Profile } [Boolean] $toReturn = $false $azureRmProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile if (-not $azureRmProfile.Accounts.Count) { $toReturn = $false } else { $toReturn = $true } Write-Debug '-- end - Test-IsRmConnected --' return $toReturn } |