Office 365 and PowerShell [Azure, Exchange, & Active Directory]

Hi

This article describes how to set up, connect, and configure your terminal to administer an Azure (cloud) based Office 365 environment.

There are two parts to the O365 administration equation, Azure Active Directory, and Exchange OnlineAAD is used for your typical AD tasks e.g. managing/creating users, resetting passwords, etc. And Exchange Online is the equivalent to the Exchange Admin Center for managing mailboxes. The pre-requisites for setting up your Windows workstation to administer O365 are:

For Azure AD:

  1. A 64-bit Windows O/S (The Azure AD module only supports a 64-bit since 10/20/14)
  2. The Microsoft Online Services Sign-In Assistant for IT Professionals RTW
  3. The Azure Active Directory Module for Windows PowerShell (64-bit version) – direct link to the .msi

For Exchange Online:

  1. .NET Framework 4.5 or 4.5.1, or later
  2. Windows Management Framework 3.0 or 4.0

SETTING UP FOR AZURE ACTIVE DIRECTORY
To set up, download and install the pre-requisite .msi files (64-bit), accept the defaults. Right click and run the Windows Azure Active Directory Module for Windows PowerShell as Administrator:

8

This launches a PowerShell console pre-loaded with the AAD modules. Next we connect to the MS Online service with the command:

Connect-MsolService

9

Enter your credentials:

10

And we can start issuing commands, for example:

Get-MsolUser

11
After installing the pre-requisite .msi’s two MSOnline PowerShell modules will be added to:

  • C:\Windows\System32\WindowsPowerShell\v1.0\Modules\MSOnline
  • C:\Windows\System32\WindowsPowerShell\v1.0\Modules\MSOnlineExtended

This means in addition to administering AAD direct via the self contained Azure console, we can use the PowerShell ISE also simply by importing the MSOnline modules via the ISE first, then connecting to the MsolService:

Import-Module MSOnline
Connect-MsolService

13
SETTING UP FOR EXCHANGE ONLINE

Here is a function for connecting to Exchange Online:

    ## Function to connect to Exchange Online
function connectECP
    {
    $UserCredential = Get-Credential
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange `
    -ConnectionUri https://outlook.office365.com/powershell-liveid/ `
    -Credential $UserCredential -Authentication Basic -AllowRedirection
    Import-PSSession $Session
    }
connectECP

We can use this function from the PowerShell ISE console to authenticate to Exchange Online and start issuing commands, for example:

Get-User

12

Here is a good starting point for useful Exchange administrative cmdlets from TechNet: Exchange Online cmdlets

Thanks for reading.

Daniel

 

SOURCES
  1. Redmond Magazine: How To Connect to Office 365 Through PowerShell
  2. Community.Office365.com – Connect-MsolService
  3. Technet – AzureADHelp
  4. Technet – Connect to Exchange Online using remote PowerShell
  5. o365info – Manage Office 365 using PowerShell
  6. Support.Office.com – Assigning admin roles in Office 365
  7. Office 365 Technical Support Blog – List and Export the Admin Roles Assigned to Users in Office 365 with PowerShell
  8. Windows IT Pro – Granular administrative roles appear in Office 365
  9. Beside the Point – Getting Started with Azure Active Directory
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: