Connecting to Office 365 with PowerShell

Sharing is caring!

You can use PowerShell to manage a lot of your administrative tasks such as user management and domain management.
The following is needed to set up power shell for this.
  1. MS Online Services Assistant needs to be downloaded and installed
  2. MS Online Module for PowerShell needs to be downloaded and installed
  3. Connect to Microsoft Online in PowerShell
Download MS Online Services Assistant
Download Online Module for PowerShell
Import-Module MSOnline
Connect to MS Online in PowerShell
Open a PowerShell session and import the MS Online Module using:
Login to Office365 Subscription
$urLogon = get-credential
Create New Session
$urPSSession = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $urLogon -Authentication Basic -AllowRedirection
Import Session:
Import-PSSession $urPSSession -AllowClobber
You can Set Execution Policy to RemoteSigned or ByPass to Run Unassigned Scripts
Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Connect to MsolService
Connect-MsolService –Credential $urLogon

Leave a Reply

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