Error: The term ‘Get-Mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable program.

The blog will explain the steps on how to connect to office 365 or Exchange online protection for the management using powershell of your desktop client computer.

Connecting Steps:

  1. Open powershell with Run as Administrator on your computer

     

  2. Connect to the Office365 environment

    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://ps.outlook.com/powershell/” -Credential $cred -Authentication Basic -AllowRedirection

     

    This will popup authentication windows. Type your login id which is the User principal name and password.

     

  3. You are now authenticated into Office 365. The last step is to connect up to Office 365 by using the following Powershell command:

    Import-PSSession $session


  4. Now your powershell is ready to use and run any command here.

As an example I ran the below command

   Get-Mailbox