Verifying a connection to O365 using PowerShell

  • 7019864
  • 05-Jul-2016
  • 07-Aug-2017

Environment

Exchange/O365

Situation

I need to verify that I am able to connect to O365 using PowerShell

Resolution

Open power shell from the computer that you are running Migration ToolKit on.

Step 1: Install required software

These steps are required once on your computer, not every time you connect. However, you'll likely need to install newer versions of the software periodically.

  1. Install the 64-bit version of the Microsoft Online Services Sign-in Assistant: Microsoft Online Services Sign-in Assistant for IT Professionals RTW.

  2. Install the 64-bit version of the Windows Azure Active Directory Module for Windows PowerShell: Windows Azure Active Directory Module for Windows PowerShell (64-bit version).

Step 2: Open the Windows Azure Active Directory Module
  1. Find and open the Windows Azure Active Directory Module for Windows PowerShell by using one of the following methods based on your version of Windows:

    • Start menu   On the Start menu, enter Azure in the Search programs and files box.

    • No Start menu   Search for Azure using any of these methods:

      • On the Start screen, click an empty area, and type Azure.

      • On the desktop or the Start screen, press the Windows key+Q. In the Search charm, type Azure.

      • On the desktop or the Start screen, move your cursor to the upper-right corner, or swipe left from the right edge of the screen to show the charms. Select the Search charm, and enter Azure.

  2. In the results, select Windows Azure Active Directory Module for Windows PowerShell.

Step 3: Connect to your Office 365 subscription
  1. In the Windows Azure Active Directory Module for Windows PowerShell, run the following command.

    $UserCredential = Get-Credential
    

    In the Windows PowerShell Credential Request dialog box, type your Office 365 work or school account user name and password, and then click OK.

  2. Run the following command.

    Connect-MsolService -Credential $UserCredential
    
How do you know this worked?

After Step 3, if you don’t receive any errors, you connected successfully. A quick test is to run an Office 365 cmdlet—for example,Get-MsolUser—and see the results.

If you receive errors, check the following requirements:

  • A common problem is an incorrect password. Run Step 3 again. and pay close attention to the user name and password you enter.

  • The Windows Azure Active Directory Module for Windows PowerShell requires that the Microsoft .NET Framework 3.5.x feature is enabled on your computer. It's likely that your computer has a newer version installed (for example, 4 or 4.5.x), but backwards compatibility with older versions of the .NET Framework can be enabled or disabled. For more information, see the following topics:

  • Your version of the Windows Azure Active Directory Module for Windows PowerShell might be out of date. To check, run the following command in Office 365 PowerShell or the Windows Azure Active Directory Module for Windows PowerShell:

    (Get-Item C:\Windows\System32\WindowsPowerShell\v1.0\Modules\MSOnline\Microsoft.Online.Administration.

Additional Information

This article was originally published in the GWAVA knowledgebase as article ID 2822