Connect to Office365 using PowerShell

You want to perform administrative tasks of office365 using power shell ? then you are at the right place now.

First you need to know, how you need to prepare your power shell environment to connect to O365 and let us see how.

The below are certain pre-requisites you need to follow to get your environment ready

Prerequisites:


  • Make sure you are running Windows 7 or above.
  • Make sure you have .Net framework 3.51 feature installed.
  • Install all the missing important windows updates.
  • Install the Microsoft online Services Sign-In Assistance.
  • Install Microsoft Windows Azure Active Directory module , you can get this from the below link . Choose appropriate version.
    http://technet.microsoft.com/en-in/library/jj151815.aspx
Once you meet all the above prerequisites follow the below steps to connect to office365.

  1. Open Azure power shell, run as administrator.
  2. Type the below command to import the MSOnline module.
     Import-Module MSOnline
  3. Type the below command and it will prompt for your Office365 credentials. Enter the credentials once it is prompted and click Ok
    $O365Cred = Get-Credential
  4. Now type the below command to initiate a PSSesssion to your Office 365 tenant account
    $O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection
  5. Now enter the below 2 command in the power shell.
Import-PSSession $O365Session -AllowClobber
Connect-MsolService –Credential $O365Cred

You are now ready and your power shell has established the connection to your Office365 tenant successfully.

Comment on your experience.

1 comment:

  1. I appreciate your guidance for uploading about office 365 here. I really need to know about it. Great work!

    ReplyDelete