Office 365 Connection Script with Modern Auth - Supports MFA (Multi-Factor Auth)

Script with GUI based connection to all Office 365 services that support Modern Auth and MFA - Exchange Online - SharePoint Online - Skype for Business Online - Azure AD v1 - Azure AD v2 - Azure Resource Manager - Azure Rights Manager - Security and Compliance Center

4.8 Star
20,125 times
Add to favorites
Office 365
E-mail Twitter Digg Facebook
Sign in to ask a question

  • error: Invalid input received from the user
    3 Posts | Last post Fri 10:18 AM
    • When I click to "Connect to Exchange Online", I get the Sign in popup, but instead of blank fields to enter my creds, I get the following message:
      Sorry, but we're having trouble signing you in.
      AADSTS90013: Invalid input received from the user.
      I did not have the option to enter my creds, am I missing something?
    • Same thing for me this morning
    • You must update the script variable $Tenant and $UPN for it to work
  • Connects but doesn't do anything
    2 Posts | Last post Fri 10:16 AM
    • I love this idea and what I am reading. However, when I went to test this out I get the following after the authentication completes:
      "Running the script to Connect to Azure Active Directory v2
      Completed running the script to Azure Active Directory v2 - Run the cmdlet - Get-AzureADUser - to test connection"
      Getting it with the Exchange Module as well. THoughts? 
      The powershell windows just sit there frozen and unusable 
      Could it be our use of DUO for MFA? 
    • You must open the PowerShell window in which you want to run your commands, call the script from there and then close the Form when you are done authenticating on the required systems. You are then ready to run in that powershell window the command you need
  • Connect to Microsoft Teams Powershell?
    1 Posts | Last post October 09, 2019
    • Will there be an update to connect to the MS Teams Powershell at any future time? Thanks!
  • For GCC High End point
    1 Posts | Last post June 12, 2019
    • Can you please modify this script for GCC high end point . Here is the link for GCC high 
  • Prompt to Change UPN/Tenant
    2 Posts | Last post May 18, 2019
    • We have multiple tenants and therefore different UPN's. Is there any way that a powershell true/false flag can be set to prompt for the tenant and/or UPN upon running the script? This will elevate us from needing to dive in and modify the PS variables each time we need to change the tenant we are working in.
      Thanks for the already invaluable script.
    • Not the MFA version that I am aware of.
      My other script that does not use MFA, you could theoretically save the script with the UPN variable, and just run that script (one for each tenant).
      Non-MFA Basic -
      Non-MFA Most services -
  • Help with your tool after domain controllers upgraded
    2 Posts | Last post May 06, 2019
    • Terry,
       Our company upgraded to 2016 domain controllers and now your tool will not allow me to connect to the account that I have listed in your tool. A pop-up box opens then closes and the red letters say
      New-ExoPSSession : User' returned by service does not match user '' in the request 
      have you seen this before? If so, please help
    • Looks like you are using incorrect credentials.
      This is querying Office 365 / Azure AD, so you should be using an Admin account in Azure AD and not a local domain admin account.
  • New button for Teams
    2 Posts | Last post January 09, 2019
    • Hi Terry!
      Very Nice Script
      I added a new button for the New Teams PowerShell connection.
      This is basically the actions script those:
      		Write-Host "Running the script to Connect to Teams Online"
      		Import-Module -name MicrosoftTeams
      If you want I can send you the whole script but i'm pretty sure you know much better then me how to add an extra button.
    • Thanks for that, but I wasn't going to update with Teams until the Teams PowerShell module was stable and mature.
      There still seems to be a lot of people in the community with a view that it is not stable yet.
      Thanks for your input.
  • Login each time required?
    2 Posts | Last post November 29, 2018
    • Hi does this let you login once with MFA and then that automatically lets you login to the other services? Or do you have to login each time for each service?   
      For example can I connect to MSOnlin with MFA and then that token will let me login to Exchange Online MFA without being prompted again? 
    • No. If you want to login once to all services, you cannot use MFA.
      Use this script to login once - -
      However, it is HIGHLY recommended that admin accounts are protected with MFA.
  • I really tried...
    2 Posts | Last post October 18, 2018
    • Terry let me begin by thanking you and everyone else for creating this script.  To be honest I am so new to using PS scripts but I am trying to learn more about them.
      I followed all instructions (or I thought I did).  I keep getting the below when I try and run the script.  It keeps hanging on the Get-DlpSensitiveInformationType - to test connection.  Nothing happens.  Just sits there.  Any help anyone can provide really appreciated.
      PS C:\scripts> .\Connect-O365-MFA-v2-5.ps1
      Running the script to Connect to Security and Compliance Center
      WARNING: Your connection has been redirected to the following URI:
      134.228 "
      WARNING: The names of some imported commands from the module 'tmp_myvaqqdq.yu4' include unapproved verbs that might
      make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the
      Verbose parameter. For a list of approved verbs, type Get-Verb.
      Completed running the script to Security and Compliance Center - Run the cmdlet - Get-DlpSensitiveInformationType - to test connection
    • Don't worry (much) about that warning. The script will still ran and you are connected.
  • SfB connection broken ?
    3 Posts | Last post August 27, 2018
    • Hi Terry
      First of all thanks for this great script. Been using it for some time now.
      This morning I ran into an issue connecting to SfB Online though. The authentication part runs fine, including MFA but then it sits there for awhile and then throws a .NET Unhandled exception error.
      It states:
      The running command stopped because the preference variable 'ErrorActionPreference' or common parameter is set to stop:[] Processing data from remote server failed with the following error message: The request for the Windows Remote Shell with ShellID xxxxx failed because the specified ShellID is incorrect or the Shell no longer exists on the server. Provide new ShellID or create a new shell and retry.
      I have retried several times but without success. 
      Not sure if it's due to a .NET update in the latest Windows 10 cumul update or if MS changed something on their end...
      Any tips? :-)
    • Have you tried running it from another workstation at all. I know that Windows 10 plays havoc constantly after updates. The last update killed my outgoing RDP connections. Works fine if I RDP out to the same server from a different PC, but dies on my recently updated Win 10 pc.
      Try a different PC and let me know.
    • Hey Terry,
      In typical MS way, it worked again the next day without any changes to configuration :-) so I am again a very happy user of your script!
1 - 10 of 32 Items