
PowerShell Basics: Search for Alias Email Address
If you’re in a large organization with multiple enabled email domains and you utilize a Hybrid Active Directory environment, you may run into a time where you need to find out who has a particular email domain as an alias on their account. Since alias utilize the proxyaddress attribute, you an export this nice and easy with PowerShell.
Run PowerShell as an administrator, then run the following script. Obviously, use your own domain.
(Get-ADUser -Filter * -Properties proxyaddresses).proxyaddresses | ?{$_ -match '@daveherrell.com'}
This will print out a list of users for you within the terminal. Want to export this into a CSV file? Pipe it out to a CSV file by running this:
(Get-ADUser -Filter * -Properties proxyaddresses).proxyaddresses | ?{$_ -match '@daveherrell.com'} | Export-csv -path C:\Users\dave\Desktop\domain-alias-export.csv
Nice and easy. We found ourselves using this a lot as you wind down mergers and acquisitions and you want your users to stop receiving emails from various domains.
Hope you find this helpful!
Categories
Recent Posts
- PowerShell: How to Add an Alias to Every Users Mailbox and Groups in Microsoft 365
- Slack: Disable Entra ID User using a slash command.
- Slack: Retrieve Entra ID (MS365) User Information with a slash command.
- Jira Cloud: Disabling Entra ID User Accounts via Automation and Microsoft Runbook
- Jira Cloud: Restart an Azure VM using JSM Assets and Automation