Quantcast
Channel: Microsoft Exchange
Viewing all articles
Browse latest Browse all 20055

powershell for exchange to get users with a specific email and forward domain

$
0
0

I need a powershell script that will give me a list of all users with a specific domain name and if it has a forward in place with a specific forward domain.

If I do this... I get results.

Get-Mailbox -ResultSize Unlimited | Where-Object {($_.PrimarySMTPAddress -like "*domain1.edu*")} > c:\mailboxes.txt

and if I do this.. I get results.

Get-mailcontact -ResultSize Unlimited | Where-Object {($_.PrimarySMTPAddress -like "*domain2.edu*")} > c:\mailboxes2.txt

but if I do this I get no results...

Get-Mailbox -ResultSize Unlimited | Where-Object {($_.forwardingsmtpaddress -like "*domain2.edu*")} > c:\mailboxes3.txt

and if I do this.. I also get no results..

Get-Mailbox -ResultSize Unlimited | Select-Object Name, PrimarySMTPAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses -cmatch "smtp"}} | Where-Object {($_.PrimarySMTPAddress -like "*domain1.edu*") -and ($_.forwardingsmtpaddress -like "*domain2.edu*")} > c:\mailboxes.txt

I have also tried this variation.. with no results and errors..

Get-Mailbox -ResultSize Unlimited | Where-Object {($_.PrimarySMTPAddress -like "*domain1.edu*")} |Get-mailcontact -ResultSize Unlimited | Where-Object {($_.PrimarySMTPAddress -like "*domain2.edu*")} > c:\mailboxes2.txt

and now I have been working on.. with no results and errors.

Get-ADuser -Filter * -SearchBase 'ou=test,dc=domain,dc=net' | Where-object {($ _.proxyaddresses -like "*domain1.edu*")} -and {($_.forwardingaddress -like "*domain2.edu*")} > c:\mailboxes4.txt

Can anyone help please??


Viewing all articles
Browse latest Browse all 20055

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>