How to connect to O365 Poweshells ?

We all know the importance and power of Powershell and scripts :)

In Office 365 we have luxury of 2 powershells that are available to manage Users and domain 

1. To manage domain and Portal related information called MOP (Microsoft Online Portal)
2. To manage Users, mailboxes or in other words your Exchange Online

Below I have shared the ways to connect to these 2 Poweshells
 

 

 

To connect to MOP

1. Install the Microsoft Online Services Sign-In Assistant

Choose 32 or 64 bit from the below link
https://www.microsoft.com/en-us/download/details.aspx?id=28177

                               Or

a) Sign in to the Office 365 portal (https://portal.microsoftonline.com) by using the user's new password.
b) On the Home page, in the pane on the right side, click Downloads, and then under Set up and configure your Office desktop apps, click Set up.

2. Install the Microsoft Online Services Module for Windows PowerShell
32-bit
64-bit

3. Go to Start and open Microsoft Online Services Module for Windows PowerShell

4. Run the below command

Import-Module MsOnline

5. Connect to your Microsoft Office 365 account

                         Connect-MsolService

Use your Office 365 LiveID to login (for example administrator@domain.onmicrosoft.com )

6. Run the below command to know the list of commands available for the Msonline Module

                      Get-Command -Module MsOnline
 

 

Check out the below link to find out the list of MSOL commands that are available
https://onlinehelp.microsoft.com/en-us/office365-enterprises/hh125002.aspx

 

 

 

To connect to Exchange Cloud Server(Exchange Online)
 
1. Click Start > All Programs > Accessories > Windows PowerShell > Windows PowerShell.
 

2. Run the following command:
                                          $Cred = Get-Credential

3. In the Windows PowerShell Credential window, type the credentials of an account in your cloud organization. When you are finished, click OK.
 

4. Run the following command:
          $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection

Note: The AllowRedirection parameter enables cloud-based organizations in datacenters all over the world to connect Windows PowerShell to the cloud-based service by using the same URL.
 

5. Run the following command:
                                      Import-PSSession $Session

Check out the below link to find out the list of Poweshell commands that are available
https://help.outlook.com/en-us/140/dd575549.aspx