Microsoft 365

PowerShell Cheat Sheet: Connect to Microsoft Cloud Services (Az, AzureAD, Exchange, MSTeams)

Recently, I’ve been working on a cheat sheet to collect all the commands needed to connect to Microsoft cloud services. Now I am happy to share this information here on my blog with you. Let’s get started.

Template for Az, AzureAD, ExchangeOnline, MSTeams

The template below shows all of the most important commands for connecting to the Microsoft Cloud services. First, consider the following:

  • You need to install the required modules for each cloud service separately. Line 5 – 14 shows the required code
  • In the second part (line 20,21) the installation of the required modules is checked
  • Each section begins with the connection establishment and ends with a simple command for checking out if the connection was successfully established


Required modules:

    1. Az 
    Install-Module Az -Force -AllowClobber
    2. AzureAD
    Install-Module AzureAD -Force -AllowClobber
    3. ExchangeOnlineManagement
    Install-Module ExchangeOnlineManagement -Force -AllowClobber
    4. MSTeams
    Install-Module MicrosoftTeams -Force -AllowClobber


# Check if all required modules are installed:

Get-InstalledModule -Name Az,AzureAD,ExchangeOnlineManagement,MicrosoftTeams | 
Select-Object -Property Version,Name,Repository,InstalledLocation

### Credentials

$credaz = Get-Credential -Credential 

$credm365 = Get-Credential -Credential

### 1. Connect to Azure Cloud ###

Connect-AzAccount -Credential $credaz

### 2. Connect to Microsoft 365 Azure AD

Connect-AzureAD -Credential $credm365

### 3. Connect to Microsoft 365 Exchange Online


### 4. Connect to MicrosoftTeams

Connect-MicrosoftTeams -Credential $credm365

Hope this was helpful and you enjoyed my article. See you next time.

4 replies »

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.