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

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
// My personal settings - arminreiter.com
// list of all settings: https://github.com/microsoft/terminal/blob/master/doc/cascadia/SettingsSchema.md
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
// "initialCols": 120,
// "initalRows": 30,
"theme": "dark",
"profiles": {
"defaults": {
"acrylicOpacity": 1.0,
"useAcrylic": false,
"fontSize": 10,
"fontFace": "Cascadia Code",
"startingDirectory": "c:\\",
"background": "#000000",
"backgroundImage": "c:\\data\\tmp\\WindowsTerminal\\LogoQuerWhite.png",
"backgroundImageOpacity": 0.8,
"backgroundImageStretchMode": "none",
"backgroundImageAlignment": "topRight",
"experimental.retroTerminalEffect": false
},
"list": [
{
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore"
},
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe"
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"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"
},
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{46ca431a-3a87-5fb3-83cd-11ececc031d2}",
"hidden": false,
"name": "kali-linux",
"source": "Windows.Terminal.Wsl"
}
]
},
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}

Categories:

No responses yet

    Leave a Reply

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