Export list of users with specific domain in proxy addresses

Below is a powershell script you can use to find users in Active Directory with a specific mail domain and export the specific domain to csv.

Edit both @domain.com with the specific domain you are searching for within the users active directory proxyaddresses attribute

$users = get-aduser -filter * -Properties Name,UserPrincipalName,ProxyAddresses| ? {$_.ProxyAddresses -like "*@domain.com"}
$csvarray=@()
foreach ($user in $users) {
    $userobject= new-object PSObject # Create Array Row
    $userObject | Add-Member -MemberType NoteProperty -name "Name" -Value $($user.Name)
    $userObject | Add-Member -MemberType NoteProperty -name "UPN" -Value $($user.UserPrincipalName)
    $i=1
    foreach ($pa in ($($user.ProxyAddresses))) {
        if ($pa -like "*@domain.com") {
            $userObject | Add-Member -MemberType NoteProperty -name "Address$i" -Value $pa            
            $i++
        }
    }
    $csvarray += $userobject                    
}
$csvarray | Export-CSV c:\temp\specificproxyaddressexport.csv  -notypeinformation