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 v1 - Exchange Online v2 - SharePoint Online - Microsoft Teams - Azure AD v1 - Azure AD v2

 
 
 
 
 
4.8 Star
(51)
23,375 times
Add to favorites
Office 365
7/13/2020
E-mail Twitter del.icio.us Digg Facebook
  • Fails on Powershell 7.
    1 Posts | Last post March 06, 2020
    • Upgraded to Powershell 7 last night and when attempting to run, I get tons of error messages about failing to draw/convert sizes. Such as below.
      Line |
       292 |      $formConnectToOffice365Us.AutoScaleDimensions = '6, 13'
           |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           | Exception setting "AutoScaleDimensions": "Cannot convert the "6, 13" value of type "System.String" to
           | type "System.Drawing.SizeF"."
      
      SetValueInvocationException: \Connect-O365-MFA-v2-5.ps1:294
      Line |
       294 |      $formConnectToOffice365Us.BackColor = 'Window'
           |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           | Exception setting "BackColor": "Cannot convert the "Window" value of type "System.String" to type
           | "System.Drawing.Color"."
      
      Interestingly I can run Chris Goosen's script (https://gallery.technet.microsoft.com/Connect-EXOps1-Connect-to-4d694663) which also draws a gui box on the screen. I haven't had chance to look at the difference between the two scripts 
      Anyone else got this working or had issues running in Powershell 7?
      
  • Connect to Microsoft Teams Powershell?
    3 Posts | Last post February 29, 2020
    • Will there be an update to connect to the MS Teams Powershell at any future time? Thanks!
    • Hi Ray Bilyk,
      
      Below script allows you to connect MS Teams PowerShell. Also supports other Office 365 PowerShell modules like Azure AD, Exchange Online, SPO, Skype for Business, Security and Compliance center, etc.
      
      https://gallery.technet.microsoft.com/PowerShell-Script-to-4081ec0f
    • Hi Kathy Cooper,
      
      I've tried your script and it works fine, but in this script, I don't get asked as many times for my username/password, even though I'm using MFA. In your script, I get asked for every service requested.
      
      I also appreciate the GUI that this script has.
      
      Thanks anyway!
  • error: Invalid input received from the user
    4 Posts | Last post February 06, 2020
    • 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
    • Try this script to connect all Office 365 services.
      https://gallery.technet.microsoft.com/PowerShell-Script-to-4081ec0f
  • Connects but doesn't do anything
    2 Posts | Last post January 17, 2020
    • 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
  • 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 
      
      https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps
  • 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 -https://gallery.technet.microsoft.com/Office-365-Connection-364d270b
      Non-MFA Most services - https://gallery.technet.microsoft.com/Office-365-and-Azure-e36eabeb
  • 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 PCUser@domain.com' returned by service does not match user 'admin@domain.com' 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
      		Connect-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 - https://gallery.technet.microsoft.com/Office-365-and-Azure-e36eabeb -
      
      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:
      "https://gcc01b.ps.compliance.protection.outlook.com/PowerShell-LiveId?BasicAuthToOAuthConversion=true;PSVersion=5.1.17
      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.
1 - 10 of 33 Items