This blog post is intended to provide Office 365 administrators with the information necessary to connect PowerShell to the Office 365 interfaces for Exchange Online and Windows PowerShell endpoints to manage their O365 tenant.
There have been many questions on how to connect to Office 365 via PowerShell. To simplify the entire experience, I’ve created a script to connect an administrator to both endpoints at once.
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Cred -Authentication Basic -AllowRedirection
Connect-MsolService –Credential $cred
This will only prompt once for credentials and any further cmdlet used that requires credentials to be passed can simply be bypassed by using ‘-Credential $cred’ where appropriate.