如何使用Windows Powershell查询Acive目录以获取userprincipalname,公司电话和职务

时间:2015-05-07 13:51:08

标签: windows powershell active-directory ldap

这里有一些新的脚本。目前使用广告模块进行电源外壳。所以我希望能够查询userprincipalname,公司电话和职位。最后,我想把它放到excel表上,这样我就可以找到那些没有电话号码或职位的人。导出并不是一件大事,因为我可以从PowerShell中选择它。

我可以使用以下查询获取姓名和公用电话

Get-AdUser -Filter * -Properties OfficePhone | FT OfficePhone,UserPrincipalName

我认为这可能就像在最后添加Title一样简单,但是这不起作用。非常感谢任何帮助,并提前感谢您!

1 个答案:

答案 0 :(得分:2)

你必须告诉它你想获得头衔:

Get-AdUser -Filter * -Properties OfficePhone,Title | FT OfficePhone,UserPrincipalName,Title