0

我正在使用 powershell 来提取 Exchange 2003 用户的列表,并基于用户的邮箱“LegacyDN”,我希望使用 LDAP 查询来提取他们的 activesyncenabled 属性(msExchOmaAdminWirelessEnable)、描述和办公室;但是,它似乎并没有出现在我身上。有任何想法吗?

这是我查询 AD 属性的方式:

$allusers = get-wmiobject -class exchange_mailbox -namespace root\microsoftexchangev2 -computername srv02 | select mailboxdisplayname, legacyDN 

foreach ($user in $allusers) 
{
$obj = new-object psobject 
$exchangever = "2003" 

$tmp = [adsi]("LDAP://" + $user.legacydn) 

$obj | add-member -membertype noteproperty -name "Display Name" -value $user.mailboxdisplayname
$obj | add-member -membertype noteproperty -name "Office" -value $tmp.physicaldeliveryofficename 
$obj | add-member -membertype noteproperty -name "Description" -value $tmp.description 
$obj | add-member -membertype noteproperty -name "Activesync" -value $tmp.msExchOmaAdminWirelessEnable 

$allusersemail += $obj 

}

$alluseremail | export-csv \\srv02\logs\test.csv 
4

1 回答 1

1

这是一种方法:

$search = System.DirectoryServices.DirectorySearcher

$search.filter = "(&(homeMDB=*)(objectcategory=user)(objectclass=user))"

$props = "mailNickName","displayName","physicaldeliveryofficename","description","msExchOmaAdminWirelessEnable"

$道具 | foreach { [void]$search.PropertiesToLoad.Add($_) }

$users = $search.findAll()

foreach($u in $users)

{

$DisplayName = @{name="DisplayName";表达式={$u.properties.item("DisplayName")}}

$Office = @{name="Office";表达式={$u.properties.item("physicaldeliveryofficename")}}

$Description = @{name="Description";表达式={$u.properties.item("Description")}}

$Activesync = @{name="Activesync";表达式={$u.properties.item("msExchOmaAdminWirelessEnable")}}

$u | 选择 $DisplayName,$Office,$Description,$Activesync

}

于 2009-02-16T11:31:01.910 回答