Powershell: How to connect to Microsoft Cloud Services like Az, AzureAD, Exchange, Teams
When I was working with Microsoft Azure Services, I started listing important commands which can be handy using PowerShell, so here I am publishing in my blog article below.
Prerequisites before starting:
Tools needed: Run the below commands in PowerShell to install the tool.
- Az: Install-Module Az -Force -AllowClobber
- AzureAD: Install-Module AzureAD -Force -AllowClobber
- ExchangeOnlineManagement: Install-Module ExchangeOnlineManagement -Force -AllowClobber
- Microsoft Teams: Install-Module MSTeams -Force -AllowClobber
step #1: Before proceeding further Check weather required modules are installed using below command:
Get-InstalledModule -Name Az,AzureAD,ExchangeOnlineManagement,MSTeams |
Select-Object -Property Version,Name,Repository,InstalledLocation
Step #2: Store account credentials in a variable
$accountz = Get-Credential -Credential <youemail@domain.com>
$account365 = Get-Credential -Credential <youemail@domain.com>
Below are the commands you can use to connect
Azure Cloud
Connect-AzAccount -Credential $accountz
Get-AzVM
Microsoft 365 Azure AD
Connect-AzureAD -Credential $account365
Get-AzureADUser
Microsoft 365 Exchange Online
Connect-ExchangeOnline
Get-Mailbox
MSTeams
Connect-MicrosoftTeams -Credential $account365
Get-Team
I hope will commands will help . If you have any problem comment down below.
Arjun is a Full-stack developer, who is fond of the web. Lives in Chikmagalur, Karnataka, India