locked
Get-ADUser - Identifying blank displayname fields RRS feed

  • Question

  • Get-ADUser -SearchBase 'OU=Event Accounts,OU=Users,OU=Napier,DC=napier-mail,DC=napier,DC=ac,DC=uk' -filter {-not(displayname -like "*")} -Properties displayname|select name, displayname

    I am using the script above to identify blank displayname, however in some instances, the displayname is populated with a random character which I am having trouble identifying.  In SQL, I use the filter 'where (rtrim(ltrim(isnull(displayname,''))) like '')' to identify these items but was hoping someone could assist in doing this through Powershell?

    Wednesday, January 4, 2017 3:52 PM

Answers

  • What random character?

    Here's how to see what user accounts do not have a displayName attribute set:


    Get-ADUser -LDAPFilter "(!displayName=*)"


    -- Bill Stewart [Bill_Stewart]


    Wednesday, January 4, 2017 4:01 PM

All replies

  • What random character?

    Here's how to see what user accounts do not have a displayName attribute set:


    Get-ADUser -LDAPFilter "(!displayName=*)"


    -- Bill Stewart [Bill_Stewart]


    Wednesday, January 4, 2017 4:01 PM
  • Use (Length -le 1) to account for a single random character.


    \_(ツ)_/

    Wednesday, January 4, 2017 4:55 PM