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"}
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)
    foreach ($pa in ($($user.ProxyAddresses))) {
        if ($pa -like "*@domain.com") {
            $userObject | Add-Member -MemberType NoteProperty -name "Address$i" -Value $pa            
    $csvarray += $userobject                    
$csvarray | Export-CSV c:\temp\specificproxyaddressexport.csv  -notypeinformation