Here is a quick reference on how to connect to Azure, Azure AD, Office 365, and Teams with PowerShell. All the modules and steps can become cumbersome for Admins so I have compiled them into one easy place.
Connect to Azure with PowerShell:
Connecting to the Azure platform to create and manage resources it is highly recommended to use the cloud shell:
https://shell.azure.com/powershell
Connect to Azure Active Directory (AzureAD) with PowerShell:
Be aware there are currently 2 module versions available. MSOnline is the older version and AzureAD is the new version 2 that Microsoft recommends. AzureAD should eventually fully replace the MSOnline module.
Connect to MSOnline:
1 2 |
Install-Module -Name MSOnline Connect-MsolService |
Connect to AzureAD:
1 2 3 |
Install-Module -Name AzureAD $userCredential = Get-Credential Connect-AzureAD -Credential $userCredential |
Connect to Office 365 with PowerShell:
1 2 3 |
$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session |
Connect to Microsoft Teams with PowerShell:
1 2 3 4 |
Install-Module MicrosoftTeams Import-Module MicrosoftTeams $userCredential = Get-Credential Connect-MicrosoftTeams -Credential $userCredential |
Note: At the time of this blog post Microsoft has combined the Skype Online PowerShell module into MicrosoftTeams module. However, I was encountering issues such as:
The term ‘Get-CsOnlineUser’ is not recognized as the name of a cmdlet, function, script file, or operable program.
The term ‘Get-CsOnlineTelephoneNumber’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Looking into this I found that the Skype Online commands are only added if you get the preview version of the MicrosoftTeams module with this command:
1 |
Install-Module MicrosoftTeams -AllowPrerelease -RequiredVersion "1.1.9-preview" |