• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
OpenTechTips

OpenTechTips

Short Guides for IT Professionals

MENUMENU
  • HOME
  • ALL TOPICS
    • Active Directory
    • Exchange
    • InfoSec
    • Linux
    • Networking
    • Scripting
      • PowerShell
    • SSL
    • Virtualization
    • Web
    • Tools
  • ABOUT
  • SUBSCRIBE
Home » The New Way to connect to Office 365 with PowerShell

The New Way to connect to Office 365 with PowerShell

May 4, 2020 - by Zsolt Agoston - last edited on September 26, 2020

Office365 is increasingly popular among businesses as a managed email service with a plethora of features and competitive pricing. The best and most efficient way to administer your Exchange Online tenant is via Exchange PowerShell. It comes with no surprise that even the cheapest Office365 package that contains EOL comes with shell accessibility. The only question is how to access the shell easily with any machines that has PowerShell capability?

Here we sum up the two ways to do it. Both are usable as of today, the old way is using Basic authentication while the new way utilizes OAuth 2.0

You find other ways to connect to Exchange HERE

Note that Basic authentication will be deprecated on October 13, 2020!

1. New Way

Before you start, make sure the necessary PS module is installed on your system:
Install-Module –Name ExchangeOnlineManagement

Simply issue these commands:

$cred = Get-Credential
Connect-ExchangeOnline -Credential $cred

The New Way to connect to Office 365 with PowerShell

2. Old Way

The old way resembles the normal way you import PowerShell sessions, however it will likely be deprecated in the future as it is using basic authentication which is considered overall less secure than the Modern authentication method.

$cred = Get-Credential
$ExchSession = New-PSSession -ConfigurationName microsoft.exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Authentication basic -Credential $cred -AllowRedirection
Import-PSSession $ExchSession -DisableNameChecking

Reader Interactions

Community Questions Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tools

Secondary Sidebar

CONTENTS

  • 1. New Way
  • 2. Old Way

  • Terms of Use
  • Disclaimer
  • Privacy Policy