Connect to Office 365 using PowerShell

Using Powershell to connect to Office 365

Firstly, you need to create a connection to Office 365. You can do this by typing (or copying/pasting) the following into Powershell.

$UserCredential = Get-Credential

Once this is in the Powershell window, press Enter to execute the command.


Now you simply type in the username and password for an Administrator account in your Office 365 and click OK. You will probably see some warnings.  Don’t worry, they are normal.You are now authenticated into Office 365. The last step is to connect up to Office 365 by using the following Powershell command:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $session

Now you’ve gone to all the trouble of connecting to Powershell, let’s do something to prove that it works. Type the following into the Powershell window and press Enter:



Close session once completed: Remove-PSSession $Session


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 )

Connecting to %s