With an on-premises Exchange environment, you would connect using the Exchange Shell which you would need installed on the server or workstation. If you’re new to Exchange Online, things are a little different. Instead, you use the regular Windows Powershell, create a Remote Powershell Session, then run your commands.
- Open Powershell
- Type
$UserCredential = Get-Credential
and enter your credentials when prompted - Start a new session by typing:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
- Run
Import-PSSession $Session -DisableNameChecking
- End your Exchange Online Powershell by running
Remove-PSSession $Session
You can also use the TechNet Gallery Script.
You can review Microsoft’s documentation here for more information.
If you receive the error:
“Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.”
Just execute the comand:
Set-ExecutionPolicy RemoteSigned
(see https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps)