Dave Herrell - Blog - IT Toolbox - PowerShell Banner

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!