Get-AdUser where mail is not null

Question:

I am trying to get a list of all users in AD that have an email (mail attribute). I have this command

The problem is that I do not know how to limit or filter out users where the email is null/blank. I do not care how complex the script is as it will be part of a much larger powershell script. If the solution is to loop through the CSV that is an option but would prefer something quicker. Does anyone know how to do this?

Answer:

Try this:

Source:

Get-AdUser where mail is not null by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply