If you prefer to get more “straight forward” version of – Connect to Office 365 by using Remote PowerShell, you go to: Connecting to Office 365 with Remote PowerShell– PowerShell Nuggets)
The Power of PowerShell – Article Series
Step 1: Download and install required components
Before we can start the remote PowerShell session to Office 365, we need to download the required cmdlets. Additional pre-requirement is to: install the: Office 365 sign in assistant.
You can find the required software component using the following links:
1. Microsoft Online Services Sign-In Assistant
You can download the Microsoft Online Services Sign-In Assistant by using the following link:
Microsoft Online Services Sign-In Assistant for IT Professionals RTW
Choose the download option
Choose the right version for your OS (most of the modern OS are 64-bit version).
2. Office 365Powershell
You can download the indows Azure Active Directory Module for Windows PowerShell by using the following link:
Windows Azure Active Directory Module for Windows PowerShell
Click on the link named: Azure Active Directory Module for Windows PowerShell (64-bit version)
After the installation of PowerShell cmdlets, we will find a new icon on the desktop named: Microsoft Online Services Module for Windows PowerShell.
(An additional option is to use: start menu > All Programs > Microsoft online services> Microsoft online service module for Windows PowerShell
Microsoft Online Services Module for Windows PowerShell
The Microsoft Online Services Module for Windows PowerShell shortcut includes a command the will imports Office 365 cmdlets to the PowerShell console.
Technically we don’t have to use this shortcut. We can manually import the 365 cmdlets to the PowerShell console by using the command: Import-Module MSOnline
Step 2: First time configurations
I must admit that the First-time configurations is a little a bit “Naggers” but, after creating the required settings, the next time will be easier. The PowerShell remote connection requires the following configuration settings:
1 – Run as Administrator
To be able to change the PowerShell Execution Policy, we need to run PowerShell console, by using the option: Run as administrator.
Right click on the Microsoft Online Services Module for Windows PowerShell icon and chose the option: Run as administrator.
2 – Setting the PowerShell Execution Policy
PowerShell security policy (“Execution policy”) can be defined by using one of the following options (modes): Restricted, AllSigned, RemoteSigned, and Unrestricted.
(The default mode is: Restricted).
To change the Execution policy open the Microsoft Online Services Module for Windows PowerShell and type the command:
Step 3: Connect to Office 365 by using Remote PowerShell
Open the Microsoft Online Services Module for Windows PowerShell and Type (or copy and paste) the following command:
A pop out windows will appear. Type your credentials by using the UPN (user Principal name) format. For example: firstname.lastname@example.org
Congratulations! You are now connected to the Office 365.
PowerShell Interface is a little bit “stingy” in providing Indication such as: “you are now connected”. In the PowerShell environment, the fact that we did not get any error message indicates that “everything is O.K” (most of the times).
Step 4: Verifying the remote connection
Q: How can we know if the remote session was successfully created?
A: To verify that we are connected, we can use the most basic Office 365 cmdlets:
This command will display a list all Office 365 users. In the screenshot you can see a list of Office 365 users
In this article we review the following items:
In part 3 we will learn how to crate Remote PowerShell for managing Exchange:
Watch the Video: Connect to Office 365 by – using Remote PowerShell
We really want to know what you think about the article