Add Exchange Online Shell to Windows Terminal

I really like the Windows Terminal – an awesome tool which I use daily. Some time ago, I posted my My Windows Terminal Config. These days, I added the Exchange Online Shell as another option in my config. Here is how you can add it.

Note: Exchange Online Shell does not work within powershell core, that’s why we use standard powershell.

Step 1: Install ExchangeOnlineManagement

Open Powershell (not core) as administrator and install the module “ExchangeOnlineManagement”:

Install-Module ExchangeOnlineManagement

Step 2: Verify if it works

Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline
# sign in
Get-MailUser

If Connect-ExchangeOnline throws:

Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ …

switch to “classic” Powershell. This error occurs if you use Powershell Core. ExchangeOnlineManagement only works within Powershell.

Step 3: Add Exchange Online to Windows Terminal

Open settings of Windows Terminal and add:

      {
        "guid": "{2f59be3b-a8a2-4131-98c9-e8531cbc4dd9}",
        "name": "Exchange Online Shell",
        "commandline": "powershell.exe -NoExit -Command \"Import-Module ExchangeOnlineManagement; Connect-ExchangeOnline\"",
        "background": "#012456",
        "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png"
      }

If you always use the same user, you can add “-UserPrincipalName [email protected]” to the config:

      {
        "guid": "{2f59be3b-a8a2-4131-98c9-e8531cbc4dd9}",
        "name": "Exchange Online Shell",
        "commandline": "powershell.exe -NoExit -Command \"Import-Module ExchangeOnlineManagement; Connect-ExchangeOnline -UserPrincipalName [email protected]\"",
        "background": "#012456",
        "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png"
      }

My entire Windows Terminal config

Categories:

8 Responses

  1. How did you come up with the GUID for the profile?
    I’ve read you need to use a UUID V5 generator, but I’ve not had any success.

  2. Does that GUID not have any bearing on the name of the profile?

    I was trying to come up with the Ubuntu GUID shown in the Microsoft document below by running it through various Version 5 UUID generators, but could never come up with the GUID shown.

    https://docs.microsoft.com/en-us/windows/terminal/json-fragment-extensions

    My understanding was that the GUID needed to be generated based on the profile name. But I could be completely misunderstanding all of this.

  3. Awesome tip! I use the Exchange Online to manage delegated organizations using the
    “-delegatedorganization contoso.onmicrosoft.com”
    flag. I wonder if your command line could be modified to prompt for the domain name? I played around with it for a bit, but couldn’t get it to work.

    • what a great idea! I have multiple profiles for that, but you could also use the following:


      "commandline": "powershell.exe -NoExit -Command \"Import-Module ExchangeOnlineManagement; $server = Read-Host -Prompt 'Input your server name'; Connect-ExchangeOnline -UserPrincipalName [email protected] -DelegatedOrganization $server.onmicrosoft.com\"",

  4. Hi Armin

    I copied and pasted your command to enable Exchange Online to Windows Terminal. Relaunched Windows terminal didn’t get Exchange Online as an option on the drop-down menu, nor did I get the icon either.
    Am I doing something wrong? I did create a new GUID using New-Guid PowerShell command.

Leave a Reply

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

About
about armin

Armin Reiter
Blockchain/Web3, IT-Security & Azure
Vienna, Austria

Reiter ITS Logo

Cryptix Logo

Legal information