Get-ADUser -Filter for blank Attribute RRS feed

  • Question

  • I'm trying to export a list of users with various attributes which have a particular attribute set to <not set>, 

    I've tried various combinations such as below with no luck as yet

    Get-ADUser -Filter 'extensionAttribute1 -like ""' -SearchBase 'OU=Users,DC=domain,dc=com

    Can anyone point me in the right direction?

    Thursday, January 9, 2020 5:24 AM

All replies

  • Hi,

    Thanks for your question.

    Get-ADUser -Filter {-not(extensionAttribute1 -like "*") } -SearchBase "OU=Users,DC=domain,dc=com"

    You can try to filter the blank attribute by the script example above.

    Best regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, January 9, 2020 5:49 AM
  • The filter with "" does not work, because if there is no value assigned, then the AD database does not include that attribute for the user. No "blanks" are saved in the database. The suggested filter would work, or you could use the -NotLike operator:

    Get-ADUser -Filter {extensionAttribute1 -NotLike "*"} -SearchBase "OU=Users,DC=domain,dc=com"

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Thursday, January 9, 2020 10:31 AM