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

 
 
 
 
 
(0)
Add to favorites
Active Directory
8/10/2009
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • 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){
      	$objSearcher.PropertiesToLoad.Add($i)
      	}
      
      $colResults = $objSearcher.FindAll()
      
      foreach ($objResult in $colResults)
          {
          $objResult.Properties.name
          $objResult.Properties.sAMAccountName
          $objResult.Properties.homeDirectory
          }
      
      
    • 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 = "(