How to Connect to Exchange Online using remote PowerShell

 Thank to: https://gcits.com/

If you’re going to be working with Office 365 via PowerShell, it’s a good idea to set up your computer with the appropriate PowerShell cmdlets and versions.

It’s also a good idea to create shortcuts to the various Office 365 services, so you can quickly log on to them without having to copy and paste commands one by one.

Here are some instructions on TechNet that detail the prerequisites for a connection to Exchange Online, though you might find you’ve got these installed already: https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx

Easily connect to Exchange Online via PowerShell

Open PowerShell as an administrator

Go to Start, search for PowerShell, right click Windows Powershell and Run as Administrator
Open PowerShell As An Administrator To Connect To Exchange Online

Create a PowerShell profile with a function

Run this:

1
New-item –type file –force $profile

Create A New PowerShell Profile

Then this:

1
notepad $profile

Open PowerShell Profile In Notepad

Now copy the following PowerShell function into the notepad document and save it:

(Be sure to replace elliot@gcits.com.au with your username).

1
2
3
4
5
6
7
8
9
10
11
Function Connect-EXOnline{
 
$credentials = Get-Credential -Credential elliot@gcits.com.au
Write-Output "Getting the Exchange Online cmdlets"
 
$Session = New-PSSession -ConnectionUri https://outlook.office365.com/powershell-liveid/ `
-ConfigurationName Microsoft.Exchange -Credential $credentials `
-Authentication Basic -AllowRedirection
Import-PSSession $Session
 
}

Save Exchange Online Function In Notepad

Use the new function to connect quickly to Exchange Online

Close Powershell and run it again.

From now on you can just type Connect-ExOnline, or just type connect and press TAB.

Run Function To Connect To Exchange Online

Enter your password and you’re good to go.

Get The Exchange Online Cmdlets

Now your computer is set up to connect to Exchange Online without having to copy and paste multiple commands.

Connection To Exchange Online Via PowerShell Is Successful

Comentarios

Entradas populares de este blog

Guía de herramientas básicas para estudiantes: 31 apps y webs imprescindibles para ayudarte con los estudios

Comando FOR para archivos BAT

How to Setup and Configure Your Own GitLab Server on Ubuntu 20.04