Connecting PowerShell to Office 365

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.

– Office 365 Sign In Assistant (IDCRL7) 32-bit/64-bit
– Microsoft Online Services Module for Windows PowerShell 32-bit/64-bit

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $session
Connect-MsolService –Credential $cred

Cmdlet References:
O365-specific cmdlets
Exchange Online cmdlets

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: