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 MSTeams -Force -AllowClobber


# Check if all required modules are installed:

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

### Credentials

$credaz = Get-Credential -Credential patrick.gruenauer@domain.com 

$credm365 = Get-Credential -Credential patrick.gruenauer@domain.com

### 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 MSTeams

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:

WordPress.com Logo

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

Google photo

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

Twitter picture

You are commenting using your Twitter 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.