
For many years, Exchange Online allowed inbound email using aliases but not the ability to send from email aliases.
You can tell an Exchange Online email address is an alias by looking at the lower-case smtp
: addresses in the mailbox properties. Previously, the upper-case SMTP:
address in the properties was the only address from which the user could send email. That upper-case SMTP:
address, of which there can only be one, remains the default sending address for outbound messages.
Even when aliases were for inbound use only, I still found them extraordinarily useful for things like sorting email into folders and for sites I didn’t want to have my personal address. You just couldn’t send or reply from them.
Finally, about a year or two ago Microsoft added the ability for Exchange Online to permit outbound sending of messages using aliases. How you do this depends on the client you use — with Outlook on the Mac being the one that’s the most convoluted to use.
No matter the UI difficulties, being able to send from an email alias is fantastic and (finally) makes Exchange Online more competitive with other messaging servers that have permitted this for a long time.
There’s just one problem: keeping track of all your aliases. I recently hit 90 — count ’em: ninety — aliases for my personal mailbox. I just can’t remember them all. With that many aliases, you would probably have some system for naming them, so it would be helpful to be able to quickly search for an alias without having to open Outlook or log into OWA.
I wrote the following PowerShell function to make it easy to search for an alias. And I asked GitHub CoPilot to generate the documentation for it. CoPilot did such an amazing job that I won’t bother to describe how the function works. You can just read the AI’s doc below and try the code yourself .
You will need the Microsoft.PowerShell.SecretManagement
and ExchangeOnlineManagement
PowerShell modules. These run on macOS and under PowerShell 7.4, which is where I developed this function.
Usage is simple. Put the function in your $PROFILE
and then, for example:
Find-ExoAlias [emailAlias] [mailbox]
emailAlias
can be a substring of what you are looking for; mailbox
must be a valid identity with a matching local secret.
Here’s the AI-generated doc:
The Find-ExoAlias
function is designed to search for an email alias within an Office 365 mailbox in Exchange Online. It takes two parameters: $addr
and $identity
.
Parameters:
$addr
: The email alias to search for. If this parameter is not provided when the function is called, the user will be prompted to enter it.$identity
: The identity of the Office 365 mailbox. If this parameter is not provided, the user will be prompted to enter the mailbox identity.
Behavior:
- If the
$identity
parameter is not provided, the function prompts the user to enter the Office 365 mailbox identity. - The function attempts to retrieve a secret (password) associated with the mailbox identity from the local default vault using
Get-Secret
. - If the secret does not exist, it notifies the user with a warning message and exits.
- Using the retrieved secret, it creates a
PSCredential
object. - It then connects to Exchange Online using the
Connect-ExchangeOnline
cmdlet and the credentials created in the previous step. All output from this connection attempt is redirected to null to keep the console clean. - The function retrieves the mailbox details using
Get-EXOMailbox
and stores the email addresses associated with the mailbox in$mboxAddresses
. - If the
$addr
parameter was not provided initially, the function prompts the user to enter the email alias to search for.
Note: The function assumes that the user’s password is stored in the local default vault and that the Connect-ExchangeOnline
cmdlet is available in the PowerShell session. It also assumes that the necessary modules for executing Get-Secret
, Connect-ExchangeOnline
, and Get-EXOMailbox
are installed and available.
function Find-ExoAlias($addr, $identity) { if ($null -eq $identity) { $identity = Read-Host -Prompt "Enter Office 365 mailbox identity" } $secret = Get-Secret -Name $identity # Name of the secret with the password for the Exchange Online mailbox. Requires that user's password is stored in the local default vault using the exact name of the identity if (!$secret) { # Test to see if the secret exists in the default local vault Write-Host "Secret doesn't exist in the local default vault" -ForegroundColor Yellow exit } $cred = New-Object -TypeName PSCredential -ArgumentList $identity, $secret Connect-ExchangeOnline -Credential $cred 6> $null # Connect to Exchange Online and redirect all outout to null $mbox = Get-EXOMailbox -Identity $identity $mboxAddresses = $mbox.EmailAddresses if ($null -eq $addr) { $addr = Read-Host -Prompt "Enter email alias to search for" } $mboxAddresses -match $addr | Write-Host -ForegroundColor Yellow }
Leave a Reply