Categories

Finding the users home drives

To display the home drive information for your users

"`nMicrosoft"            
Get-ADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(homeDirectory=*))" -Properties *|            
Format-Table Name, DistinguishedName, HomeDirectory, HomeDrive -AutoSize            
            
"`nAD provider"            
Get-ChildItem -Filter "(&(objectclass=user)(objectcategory=user)(homeDirectory=*))" `
 -Path Ad:\"DC=Manticore,DC=org" -Recurse |             
foreach {             
 $user = [adsi]"LDAP://$($_.DistinguishedName)"            
 $user | select @{N="Name"; E={$_.name}},             
 @{N="DistinguishedName"; E={$_.distinguishedname}},            
 @{N="HomeDirectory"; E={$_.homeDirectory}},            
 @{N="HomeDrive"; E={$_.homeDrive}}             
} | Format-Table -AutoSize            
             
"`nQuest"            
Get-QADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(homeDirectory=*))" -IncludeAllProperties |            
Format-Table Name, DN, HomeDirectory, HomeDrive -AutoSize            
            
"`nScript"            
$root = [ADSI]""            
$search = [adsisearcher]$root            
$search.Filter = "(&(objectclass=user)(objectcategory=user)(homeDirectory=*))"             
$search.SizeLimit = 3000            
$search.FindAll() | foreach {            
             
$user = $_.GetDirectoryEntry()            
$user | select @{N="Name"; E={$_.name}},             
 @{N="DistinguishedName"; E={$_.distinguishedname}},            
 @{N="HomeDirectory"; E={$_.homeDirectory}},            
 @{N="HomeDrive"; E={$_.homeDrive}}             
} | Format-Table -AutoSize


In all cases perform an LDAP search with the filter set for any occurrence of the the home directory being set.



The cmdlets can immediately display the required attributes but for the provider and script we have to get a directory entry so we can select the required attributes.

Leave a Reply