我在 PowerShell 2.0 中使用Get-QADUser和.DirectoryEntry.FirstName进行多个 LDAP 查询并返回字符串。这些多次调用很慢。我怎样才能只进行一次Get-QADUser LDAP 查询并从选择的属性中创建字符串。
例子:
ADD-PSSnapin Quest.Activeroles.ADManagement
$searchDomainFrom = 'domain.net/OUPath/Users'
$user = UserName
$FirstName = (Get-QADUser -SearchRoot $searchDomainFrom $user).DirectoryEntry.FirstName
$LastName = (Get-QADUser -SearchRoot $searchDomainFrom $user).DirectoryEntry.LastName
$Email = (Get-QADUser -SearchRoot $searchDomainFrom $user).DirectoryEntry.Email
$Supervisor = (Get-QADUser -SearchRoot $searchDomainFrom $user).DirectoryEntry.Manager
$OfficeLocation = (Get-QADUser -SearchRoot $searchDomainFrom $user).DirectoryEntry.Office
$PhoneNumber = (Get-QADUser -SearchRoot $searchDomainFrom $user).DirectoryEntry.PhoneNumber