Get-aduser with email emailaddress field

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of El Jefe El Jefe 1 year, 6 months ago.

  • Author
    Posts
  • #6332

    by Christopher.Ellis at 2013-04-26 10:07:43

    I want to run a quick powershell script which reports all users names in our active directory with empty emailaddress field
    I would start the command with get-aduser however the rest not known to me. List produced would be username Populate and emailaddress would be empty.
    Thank you

    by Christopher.Ellis at 2013-04-26 10:24:46

    get-aduser -property 'emailaddress' | select-object -property name, emailaddress

    I got this far, however if I wanted to state emailaddress = empty display name the above command gets all accounts

    by Martin9700 at 2013-04-26 10:30:03

    Kind of a goofy one, evidently Get-ADuser doesn't recognize the $null variable within a filter but I found this to work:

    Get-ADUser -Filter {EmailAddress -notlike "*"} -Properties EmailAddress | Select Name

    by Christopher.Ellis at 2013-04-26 10:41:29

    Thank you

  • #30321
    Profile photo of El Jefe
    El Jefe
    Participant

    Instead of the '-notlike "*"' you could use '-le 0'

You must be logged in to reply to this topic.