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
(44)
16,759 times
Add to favorites
Office 365
10/2/2017
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Connections close mid-use
    3 Posts | Last post April 10, 2018
    • As others have said, thank you so much for creating this. When we swapped to MFA I lost use of some great scripts of mine and this resolved that. For some reason, mid-use I will be disconnected. Recently I've been doing mostly single line commands that are not using a script and it will still happen between two commands, not after a five minute break timeout or something similar if that exists. When connecting without MFA I don't have this problem, but with the MFA it happens. I searched your script and couldn't find any setting related to a duration. Any idea what could be causing this?
    • Quick addition: When using the Powershell window that opens via the Exchange Online link I do not have this problem.
    • This is a known issue with PowerShell ISE.
      Does this happen when you run the scripts in EMS ?
  • Powershell window closes when 'OK' is clicked in GUI
    2 Posts | Last post March 25, 2018
    • Hello - Thank you for providing this script.  It sure helps when connecting to Skype for Business in Office 365.  I am running into an issue that I was hoping you could help with.  If I run the script from an already open PowerShell window, it works fine.  I am able to click 'OK' and the GUI window closes allowing me to interact with the PowerShell window.  If I however run the script by right clicking and choosing 'Open with PowerShell', everything works fine until I click 'OK' in the GUI window.  The PowerShell window then closes.  Any ideas would be greatly appreciated.
    • No idea on the underlying issue, but it could be something to do with how the GUI works. I have only ever tested and used by starting PowerShell first, and then running the script from there.
  • Can't get this working on server 2016.
    2 Posts | Last post March 25, 2018
    • I set up brand new patched server 2016.  I cannot get this working.  install microsoft sign in assistance then install-module MSONLINE.  Then import-module MSONLINE.
      
      Then connect-msolservice.
      
      I see a quick flash of a logon screen and then error message.  I've been stuck for hours please help what is required to run this thing on windows server 2016????
      
      PS C:\Windows\system32> Install-Module -Name MSOnline
      PS C:\Windows\system32> import-module MSOnline
      PS C:\Windows\system32> connect-msolservice
      connect-msolservice : Authentication Error: Unexpected authentication failure.
      At line:1 char:1
      + connect-msolservice
      + ~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : OperationStopped: (:) [Connect-MsolService], Exception
          + FullyQualifiedErrorId : System.Exception,Microsoft.Online.Administration.Automation.ConnectMsolService
      
    • This looks like a user name and password issue.
      Try logging into the Office 365 Portal with those credentials to confirm.
  • Shell Hangs periodically
    3 Posts | Last post December 20, 2017
    • Great script! I just updated to 2-5. 
      I find that the shell window will lock up requiring me to right-click close it.  I can reconnect and be fine again for a random period of time. 
      I will try to replicate this situation on another machine. 
      The workstation is Windows 10. Using it with PowerShell ISE.
    • Yes... it hangs in ISE.
      Seems to be stable in PowerShell.
      I have it hang on multiple workstations with multiple configurations.
      I have had issues with the Exchange PowerShell connection, but none with Azure AD.
      I have updated my doco to reflect using PowerShell rather than ISE.
      I much prefer ISE, but it looks like I need to create my scripts in ISE, and then run in PowerShell.  :(
    • Hi Terry, 
      first of all, great, great script. This is a time saver for many of us.
      
      As many of us also do want to use ISE, could a part of the solution can be found in this link:
      
      https://support.microsoft.com/en-us/help/943139/windows-forms-application-freezes-when-system-settings-are-changed-or
      
      and this info
      
      Issue
      The application will not respond and the UI thread will hang in an Invoke call while handling the OnUserPreferenceChanged notification
      Cause
      This occurs if a control is created on a thread which doesn't pump messages and the UI thread receives a WM_SETTINGCHANGE message.
      Resolution
      Applications should never leave Control objects on threads without an active message pump. If Controls cannot be created on the main UI thread, they should be created on a dedicated secondary UI thread and Disposed as soon as they are no longer needed.
      
      ?
      
  • Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
    2 Posts | Last post December 06, 2017
    • Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      Skype customer Support Number +1 (844) 296 1666 Skype Tech Support Number
      
      
    • Please ignore this scam. I have reported to Microsoft.
  • Publish to Powershell Gallery?
    1 Posts | Last post November 30, 2017
    • Great script. You should publish this to powershell gallery so it can easily be installed by "Install-Script connect-o365-mfa -scope currentuser"
      
      Here's a quick tutorial. Thanks again!
      http://www.brianbunke.com/blog/2017/01/09/publishing-scripts/  
  • Bad Request
    3 Posts | Last post November 23, 2017
    • I am getting the same issue and we use MFA.  When I run the Exchange Online module by itself it works fine so I know my connection is good.  The Azure AD v2 option works and brings up the new window where I can enter my credentials.  The Exchange Online option only brings up the new window with the error below (doesn't prompt for any sign in):  
      
      Sorry, but we’re having trouble signing you in. 
      We received a bad request.
      Additional technical information: 
      Correlation ID: 0c0610c3-e607-4163-a478-146b6dcc8553 
      Timestamp: 2017-11-23 16:04:25Z 
      AADSTS90013: Invalid input received from the user. 
      
      
      
    • Sorry I didn't read the first part of the script to manually edit the script to update the $UPN and tenant variables.  Anyway to change this so that it will prompt for the UPN variable?  Will make it much more user friendly for users that are not script editors.
    • Hi Slinghotz,
      I have tried to make the script as easy as possible and to try and minimise the prompts for information as much as possible. That is why I added the UPN variable so that some of the services pre-populate the script with the UPN and save you entering it each time. Currently, only a few Office 365 services pre-populate the UPN from the script. Most force you to enter your UPN as well as your password and MFA code.
      
      In regards to the prompts you will receive from the MFA script, follow this guide to understand how it works - http://www.365admin.com.au/2017/07/how-to-connect-to-office-365-via.html . 
      
      Updating my script before you run it helps with SharePoint connections as it updates you connection to point directly to your tenant.
      
      It really is important to read my guides to ensure your connection experience is pain free.
      
      If you just want a single script that you edit once with no more prompts to connect to all Office 365 services, download this script - https://gallery.technet.microsoft.com/Office-365-and-Azure-e36eabeb - Note that it doesn't support modern auth / MFA.
      
      Cheers,
  • problem running script
    2 Posts | Last post November 23, 2017
    • additional info to my previous question:
      
      Additional technical information: 
      Correlation ID: caa9b3a5-f423-4e5d-b29c-07f3fd4ca4af 
      Timestamp: 2017-11-22 16:43:20Z 
      AADSTS90013: Invalid input received from the user 
      
    • See below on the Discussions page. Another user had the same issue as they entered the UPN incorrectly.
  • Excited to find this but does not work for me
    1 Posts | Last post November 22, 2017
    • 
      Thanks for putting this together!
      
      The script loads and displays the gui, but when I click one of the options to connect, I receive a "Sorry, we're having trouble signing you in.   We received a bad request" (tried from two machines)  
      
      I am guessing something changed on the Microsoft side as others had success with the script?
      
      
  • Received a bad Request.
    2 Posts | Last post November 10, 2017
    • When I try to login to Exchange Online with a MFA enabled account, the pop-up that appears says "Sorry, but we're having trouble signing you in. We received a bad request."
      
      At the bottom
      Additional technical information: 
      Correlation ID: c51d1fe9-d102-495e-8101-c3bd18934a28 
      Timestamp: 2017-11-10 22:04:10Z 
      AADSTS90013: Invalid input received from the user. 
      
      
      Some of the other connections do prompt for credentials properly and work (Azure AD v2 for example).
      Thanks,
      
      Conor
    • I set my UPN incorrectly. Solved. Sorry!
11 - 20 of 29 Items