0

出于某种原因,除了 homeDirectory 之外,一切正常。为此,一切都是空白的。AD 实际上具有这些字段的值,但此脚本未显示该属性的任何内容。有任何想法吗?

  $objSearch = New-Object System.DirectoryServices.DirectorySearcher 
  $objSearch.PageSize = 15000 
  $objSearch.Filter = $ObjFilter 
  $objSearch.SearchRoot = "LDAP://$dn" 
  $AllObj = $objSearch.FindAll() 
foreach ($Obj in $AllObj) 
      { $objItemS = $Obj.Properties 
             $Ssamaccountname = $objItemS.samaccountname 
             $SsamaccountnameGN = $objItemS.givenname 
             $SsamaccountnameSN = $objItemS.sn 
             $SsamaccountnameEN = $objItemS.mail
             $SsamaccountnameLS = $objItemS.homeDirectory
             "$Ssamaccountname`t$SsamaccountnameGN`t$SsamaccountnameSN`t$SsamaccountnameEN`t$SsamaccountnameLS" | Out-File $UserInfoFile -encoding ASCII -append 
      } # End of foreach
   } # End of ForEach-Object 
4

2 回答 2

0

您可以在以下内容之前重试添加此行FindAll

$objSearch.PropertiesToLoad.Add("homeDirectory");

一般来说,最好将要检索的每个属性添加到搜索中。

于 2013-05-07T05:35:23.753 回答
0

如果您不喜欢使用 .NET,我真的很喜欢Quest Active Directory cmdlet

您的命令将是:

get-qadUser <UserName or another unique attribute> | Format-List <Attributes> | Out-File MyTextFile.txt

要获取可能的属性列表,您可以:

get-qaduser UserName -includeAllAttribute | fl * | Out-File C:\AllAttributes.txt
于 2013-05-07T13:26:31.110 回答