Or, Connecting Office365 Server PowerShell admin console.
Steps:
1. Open Windows PowerShell (Run as Administrator)
2. Run below command sequentially (one by one).
-----------------------------------------------------------------------------------------------------------------
Set-ExecutionPolicy RemoteSigned---------------------------------------------------------------------------------------------------------------
$LiveCred = Get-Credential
----------------------------------------------------------------------------------------------------------------
Note: (in the pop-up window, please enter Office365 global admin credentials, preferably administrator@yourdomain.com)
-----------------------------------------------------------------------------------------------------------------
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection
-----------------------------------------------------------------------------------------------------------------
Import-PSSession $Session
----------------------------------------------------------------------------------------------------------------
(All above mentioned commands are highlighted in below screenshot sequentially)
Now you can execute any administrative command from here as
you are connected to your Office365 Server successfully.