Connect Exchange Online using PowerShell

Connect Exchange Online using PowerShell

Managing Exchange online with PowerShell requires you to connect with Exchange Online. Few months ago i was working on automating the process of connecting with Exchange online rather then writing the cmdlets every time i connect with Exchange online and you know what i come up with ? Powershell Function which makes it so easy for me to connect to Exchange Online anytime i want to and i don’t have to write cmdlets every time. The function is as below.

# PowerShell Function to connect with Exchange Online

Function Connect-ExchOnline {
$ExchOnlineCred = Get-Credential

Write-Output “You are Connecting to Exchange Online. After successful authentication PowerShell will load Exchange Online Cmdlets”

#Create remote Powershell session with Exchange Online
$ExchOnlineSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/PowerShell -Credential $ExchOnlineCred -Authentication Basic -AllowRedirection

#Import the remote PowerShell session

Import-PSSession $ExchOnlineSession -AllowClobber | Out-Null
}

2

3

You can download this PowerShell function script from Technet Gallery. This script is basically a function and I didn’t “call” the function in the script self. Try dot-sourcing the script first and then running it using Connect-ExchOnline and enter your Office 365 admin credentials to connect.

The following two tabs change content below.

Riaz Javed Butt

Riaz is a technology evangelist with over 8 years of extensive experience with expertise on Identity Management, Exchange Server, Office 365 and a bit of System Center. Riaz is currently working as Lead Consultant. His technical experience is followed by 8 years consulting positions advising both internal and external customers on strategic technology selection and adoption along with delivery of solutions across a range of business units. Riaz is a regional lead speaker for Microsoft Office 365 and also speaks in community forums.

4 Comments

  1. Pingback: Configuring Office 365 Message Encryption

  2. Pingback: Active Sync and Outlook client to access Shared Mailbox

  3. Pingback: Office 365 Shared Mailbox Sent Items Limitation – Microsoft Expert Talk

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *