To be able to create a remote PowerShell session to Exchange Online, we can use the “windows built PowerShell console”.
We will need to use some “first-time” configurations and then, the rest of the process includes running the required PowerShell command for connecting to Exchange Online.
PowerShell console – First-time configuration
To be able to find the built-in PowerShell console, use the search option in the start menu by looking for the word PowerShell.
In the search results, we can see the required PowerShell console named – Windows PowerShell
To be able to run the required PowerShell commands, we will need to activate the Windows PowerShell console using the option of – Run as administrator
Right click on the Windows PowerShell icon and choose the menu – Run as administrator
We will need a PowerShell command that will provide the required permission for running PowerShell command
In the following screenshot, we can see an example. To execute the PowerShell command, press the ENTER key
Running the PowerShell set of command for connecting Exchange Online
The connection to Exchange Online by using remote PowerShell is implemented by using three sets of PowerShell command.
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Technically, we can copy this set of command and paste it on the windows PowerShell console.
When we use the option of “copy and paste” for paste a “long set” of PowerShell command we can experience some problem which relate to problems such as – spaces etc.
If you experience such problems, try to paste the PowerShell command by copy and paste each one of the PowerShell command set.
Step 1#3 – using the credentials PowerShell command
Copy and paste the following PowerShell command
As a result, an authentication window will appear
Type in your Office 365 global administrator credentials.
Step 2#3 – connecting to Exchange Online
The following PowerShell command serves for specifying the Exchange Online URL address that is used for the remote PowerShell session
Step 3#3 – Import Exchange Online PowerShell cmdlets
This is the last phase; which we import all of the Exchange Online cmdlets to the existing PowerShell console.
Copy and paste the following PowerShell command
In the following screenshot, we can see the result.
Verifying that the remote PowerShell connection was successfully completed
In case that you want to verify the remote PowerShell session to Exchange Online was successfully completed, you can try to run basic PowerShell cmdlets such as
Get-Mailbox
In the following screenshot, we can see the result of the Get-Mailbox command.
We really want to know what you think about the article
The post Connect to Exchange Online using PowerShell appeared first on o365info.com.