Link to home
Start Free TrialLog in
Avatar of itmti
itmti

asked on

Exchange 2013 - powershell script to find users with specific domain missing from them

Hi,

We cannot enable Automatically update all users to have email policy applied as some have to be managed manually.

Looking for help for powershell script to export users that are missing specific domain in their address list.

Any suggestions?
ASKER CERTIFIED SOLUTION
Avatar of James Barrack
James Barrack
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itmti
itmti

ASKER

That script just exported all of them, even the ones with @domain.com

We need help to export users that are missing @domain.com

Any suggestions?

Thanks
You didn't remove the wildcard before the @ symbol, correct?
Avatar of itmti

ASKER

no, all stayed same just modified domain.com with proper domain and destination drive for csv
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itmti

ASKER

errors

[PS] C:\>Get-Recipient -resultsize unlimited | Where {($_.EmailAddresses -le "*@domain.com")} | select name,alias,primarysmtpaddress | ft -wrap -autosize | out-file c:\Users-without-domain.csv


Where : Could not compare "x500:/o=ExchangeLabs/ou=Exchange Administrative Group (FYD111111)/cn=Recipients/cn=group9e285d0f" to "*@domain.com". Error: "Unable to cast objectof type 'Microsoft.Exchange.Data.SmtpProxyAddress' to type 'Microsoft.Exchange.Data.CustomProxyAddress'."
At line:1 char:39
+ Get-Recipient -resultsize unlimited | Where {($_.EmailAddresses -le "*@domain. ...
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Where-Object], RuntimeException
    + FullyQualifiedErrorId : ComparisonFailure,Microsoft.PowerShell.Commands.WhereObjectCommand

[PS] C:\>

Open in new window

Need to replace the @domain.com with the actual name of the domain alias that is missing from the others. For example if the alias should end in @gmail.com, then that is what the @domain.com part should be.
Avatar of itmti

ASKER

yes its replaced, im just not pasting my script here as we dont want to expose company information.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, I thought so...just making sure. It looks like you are testing this in a lab. If so, do you have the domain you are looking for added as an Accepted Domain?