Connect PowerShell to Office 365 services

Unlike the on-premise set-up, it pretty easy to start the session, but with Office 365, you need to connect to each services and you also need to use the right module.

Connect to Exchange Online (use windows Exchange PS or Azure AD PS)

  • Set-ExecutionPolicy RemoteSigned  /Use global admin credential/
  • $cred = get-credential
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection
  • Import-PSSession $Session

Connecting to AzureAD Preview (Use Azure Active Directory Shell)

  • Uninstall-Module AzureADPreview
  • Install-ConnectAzureADPreview
  • Connect-AzureADconnect

Connect to SharePoint Online (Use SharePoint Online Management Shell)

Connect to Microsoft o365 (You may use the regular PowerShell. This is for managing users, groups, etc)

  • Connect-MsolService
  • $cred = Get-Credential
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection
  • Import-PSSession $Session

 

Reference: Connect PowerShell to Office 365 services

 

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: