How to Connect PowerShell to SharePoint Online

Prerequisites:

  1. Have access to SharePoint Online as Administrator (Global Admin or SharePoint Online Administrator. Don’t already have access? Get free try for one month at https://products.office.com/en-us/try
  2. Install the Windows PowerShell 3.0 from Windows Management Framework 3.0 https://www.microsoft.com/en-us/download/details.aspx?id=34595
  3. Install SharePoint Online Management Shell
    https://www.microsoft.com/en-us/download/details.aspx?id=35588.
  4. Know your tenant name.  You will need to use it in step 3 below.

Steps:

  1. Launch Windows PowerShell or Windows PowerShell ISE
  2. Execute cmdlet Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
  3. Connect-SPOService -url https://<tenant>-admin.sharepoint.com (you will be prompted for your Office 365 credential.)
  4. Get-SPOSite should show all Site Collections provisioned.  If not, something did not go right for your in step 1 to 3.

Congrats, you now have access to all SharePoint Online PowerShell commands to manage SharePoint Online in Office 365.

Reference:

https://technet.microsoft.com/en-us/library/fp161362.aspx

How to connect PowerShell to Azure AD

Prerequisites:

  1. Have access to Office 365 as Administrator. Don’t already have access? Get free try for one month at https://products.office.com/en-us/try
  2. Install Microsoft Online Services Sign-In Assistant for IT Professional BETA https://www.microsoft.com/en-us/download/details.aspx?id=39267
  3. Install Azure Active Directory Module for Windows PowerShell (64-bit)
    http://go.microsoft.com/fwlink/p/?linkid=236297. 32-bit has been discontinued as of October 20, 2014 (http://go.microsoft.com/fwlink/p/?linkid=236298)

Steps:

  1. Launch Windows PowerShell or Windows PowerShell ISE
  2. Execute cmdlet Import-Module MSOnline
  3. Execute cmdlet Connect-MsolService

Congrats, you now have access to all PowerShell commands to manage Azure Active Directory in Office 365.

Reference:

http://technet.microsoft.com/en-us/library/jj151815.aspx