Connect to Azure AD, MSOnline or Intune API with PowerShell

How to connect to Microsoft Azure Active Directory, Microsoft 365 or the Intune API through Microsoft Graph with PowerShell.

# Get the admin credentials:
$AzureAdCred = Get-Credential

# Azure Active Directory PowerShell for Graph module
Find-Module -Name AzureAD | Install-Module
Import-Module AzureAD
Connect-AzureAD -Credential $AzureAdCred

Find-Module -Name MSOnline | Install-Module
Import-Module MSOnline
Connect-MsolService -Credential $AzureAdCred

Find-Module -Name Microsoft.Graph.Intune | Install-Module
Connect-MSGraph -Credential $AzureAdCred