如何在分发列表中获取联系人的手机号码?

问题描述 投票:0回答:1

我想获取我在分发列表中找到的Exchange联系人的移动电话号码

$result = Get-DistributionGroupMember Target-Group | where{$_.externalemailAddress -eq "Target-Address"}

$result | select-object -property mobilephone

似乎与使用set-contact不同,手机不是属性,所以最后一行不会返回任何内容。 $ results有信息,如果我将手机发送到手机,我会得到目标的工作号码,但这不是我想要的

powershell exchangewebservices
1个回答
0
投票

这是因为没有使用该cmdlet的称为MobilePhone的属性(有一个名为Phone)(我说这是因为我刚检查了使用它的用户的所有道具),除非您重新调整其中一个CustomAttributes。因此,您可以使用它来获取成员,但是您必须调用Get-ADUser或Get-ADObject来获取MobilePhone属性。

试试这个...

#Get a specific user object with the mobile property
Get-ADUser <username> -Properties MobilePhone
Get-ADObject -Filter { sAMAccountName -eq '' } -Properties MobilePhone

或这个...

#Get the members of a group and return their user object with the mobile property
Get-ADGroupMember <GroupName> | Get-ADUser -Properties mobile

所以,对于你的用例,也许是这样的......

(
Get-DistributionGroupMember -Identity '*' | 
Where-Object -Property RecipientType -EQ UserMailbox
).Name | 
ForEach { Get-ADUser -Identity $PSItem -Properties Name, MobilePhone }
© www.soinside.com 2019 - 2024. All rights reserved.