Script to Compare List of Email Addresses in Exchange
I was provided a list of email addresses of employees in a system that doesn't interface with AD/Exchange and asked to validate those email addresses exist within our Exchange server. I figured the easiest way was to just script it (the list was close to 1000 people). Total run time to compare the list was just a few seconds.
Here's the (quite simplistic) script to accomplish the task. [code language="powershell"]
$logFile = 'c:\scripts\IsAccountValid.log'
# Uncomment the entry below if not running from the EMS # Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
# Import the email addresses from text file $Import=Get-Content "c:\Scripts\emailaddresses.txt"
ForEach ($address in $import) { \(valid = get-mailbox -an \(address If (\)valid) { "\)address is Valid" >> \(logFile } else { "\)address is Not Valid" >> $logFile } } [/code]