Search for All Users Who Have a Home Directory

Sample script that searches Active Directory for all the users who have a home directory. The homeDirectory attribute is not replicated to the Global Catalog; you cannot connect t

Add to favorites
Active Directory
E-mail Twitter Digg Facebook
  • Properties don't show up
    2 Posts | Last post May 27, 2010
    • Hi 
      I tried to extend the script to show other properties in the output, but no luck. Do you know what's wrong?
      $strFilter = "(&(objectCategory=User)(homeDirectory=*))"
      $objDomain = New-Object System.DirectoryServices.DirectoryEntry
      $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
      $objSearcher.SearchRoot = $objDomain
      $objSearcher.PageSize = 1000
      $objSearcher.Filter = $strFilter
      $colProplist = "sAMAccountName","name","homeDirectory"
      foreach ($i in $colPropList){
      $colResults = $objSearcher.FindAll()
      foreach ($objResult in $colResults)
    • OK, got it... 
      With C# I'm used to match the upper and lower case of an attribute, but Powershell does not seem to like this. Using all lowercase it works like a charm :)
      $strFilter = "(