Pre-requisites
- Your account must be member of the corresponding Microsoft 365 admin role you’re going to administer.
- Your computer must use 64-bit version of latest Windows releases, at a minimum:
- Windows 7 SP1 (with .NET Framework 4.5.x and 3.0 or 4.0)
- Windows Server 2008 R2 SP1 (with .NET Framework 4.5.x and 3.0 or 4.0)
- Have installed following Modules
- Allow running signed scripts in your system
1
| Set-ExecutionPolicy RemoteSigned
|
Using a Password
1
| $credential = Get-Credential
|
Azure Active Directory PowerShell for Graph Module
1
| Connect-AzureAD -Credential $credential
|
Azure Active Directory Module for Windows PowerShell
1
| Connect-MsolService -Credential $credential
|
SharePoint Online
1
2
| Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://<domainhost>-admin.sharepoint.com -credential $credential
|
Skype for Business Online
1
2
3
| Import-Module SkypeOnlineConnector
$sfboSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfboSession
|
Exchange Online
1
| Connect-ExchangeOnline -Credential $credential -ShowProgress $true
|
Teams
1
2
| Import-Module MicrosoftTeams
Connect-MicrosoftTeams -Credential $credential
|
Microsoft 365 Security & Compliance Center
1
2
3
|
$SccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $SccSession -Prefix cc
|
Close Down all connected sessions
1
| Remove-PSSession $sfboSession ; Remove-PSSession $SccSession ; Disconnect-SPOService ; Disconnect-MicrosoftTeams
|
AzureAD and all Microsoft365 from Azure Active Directory PowerShell for Graph module
1
2
3
4
5
6
7
8
9
10
11
12
13
| $orgName="<for example, litwareinc for litwareinc.onmicrosoft.com>"
$credential = Get-Credential
Connect-AzureAD -Credential $credential
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -credential $credential
Import-Module SkypeOnlineConnector
$sfboSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfboSession
$SccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $SccSession -Prefix cc
Connect-ExchangeOnline -Credential $credential -ShowProgress $true
Import-Module MicrosoftTeams
Connect-MicrosoftTeams -Credential $credential
|
AzureAD and all Microsoft365 from Azure Active Directory Module for Windows PowerShell module
1
2
3
4
5
6
7
8
9
10
11
12
13
| $orgName="<for example, litwareinc for litwareinc.onmicrosoft.com>"
$credential = Get-Credential
Connect-MsolService -Credential $credential
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -credential $credential
Import-Module SkypeOnlineConnector
$sfboSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfboSession
$SccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $SccSession -Prefix cc
Connect-ExchangeOnline -Credential $credential -ShowProgress $true
Import-Module MicrosoftTeams
Connect-MicrosoftTeams -Credential $credential
|
Using Modern Authentication (MFA)
Single block to connect to Azure AD, SharePoint Online, Skype for Business, Exchange Online, and Teams
1
2
| $acctName="<UPN of the account, such as belindan@litwareinc.onmicrosoft.com>"
$orgName="<for example, litwareinc for litwareinc.onmicrosoft.com>"
|
Azure Active Directory PowerShell for Graph Module
Azure Active Directory Module for Windows PowerShell
SharePoint Online
1
| Connect-SPOService -Url https://$orgName-admin.sharepoint.com
|
Skype for Business Online
1
2
| $sfboSession = New-CsOnlineSession -UserName $acctName
Import-PSSession $sfboSession
|
Exchange Online
1
| Connect-ExchangeOnline -UserPrincipalName $acctName -ShowProgress $true
|
Teams
1
2
| Import-Module MicrosoftTeams
Connect-MicrosoftTeams
|
AzureAD and all Microsoft365 from Azure Active Directory PowerShell for Graph module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| $acctName="<UPN of the account, such as belindan@litwareinc.onmicrosoft.com>"
$orgName="<for example, litwareinc for litwareinc.onmicrosoft.com>"
#Azure Active Directory
Connect-AzureAD
#SharePoint Online
Connect-SPOService -Url https://$orgName-admin.sharepoint.com
#Skype for Business Online
$sfboSession = New-CsOnlineSession -UserName $acctName
Import-PSSession $sfboSession
#Exchange Online
Connect-ExchangeOnline -UserPrincipalName $acctName -ShowProgress $true
#Teams
Import-Module MicrosoftTeams
Connect-MicrosoftTeams
|
AzureAD and all Microsoft365 from Azure Active Directory Module for Windows PowerShell module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| $acctName="<UPN of the account, such as belindan@litwareinc.onmicrosoft.com>"
$orgName="<for example, litwareinc for litwareinc.onmicrosoft.com>"
#Azure Active Directory
Connect-MsolService
#SharePoint Online
Connect-SPOService -Url https://$orgName-admin.sharepoint.com
#Skype for Business Online
$sfboSession = New-CsOnlineSession -UserName $acctName
Import-PSSession $sfboSession
#Exchange Online
Connect-ExchangeOnline -UserPrincipalName $acctName -ShowProgress $true
#Teams
Import-Module MicrosoftTeams
Connect-MicrosoftTeams
|
Note > To connect to Security & Compliance Center with Modern Authentication (MFA), you need to open Exchange Online console, then hit below buttom 
Source: https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-all-office-365-services-in-a-single-windows-powershell-window