当我运行:
get-adgroup -filter {displayname -eq'groupname'} | get-adgroupmember | 格式表名,姓,名,办公电话
唯一返回的字段是默认属性“name”。 剩下的显示空白。
如果你真的喜欢单线队员:
Get-ADGroup -Filter {displayName -eq 'groupName'} | Get-ADGroupMember |Foreach-Object {Get-ADUser -Identity $($_.SID) -Properties name,sn,givenName,otherTelephone} | Format-Table name,sn,givenName,otherTelephone
如果您想进一步操作User对象,则可能需要将它们存储在一个数组中:
$Group = Get-ADGroup -Filter {displayName -eq 'groupName'} $Members = Get-ADGroupMember -Identity $Group $Users = @() Foreach-Object -InputObject $Members -Process {$Users += (Get-ADUser -Identity $_.SID -Properties *)} $Users | Format-Table name,sn,givenName,otherTelephone
您可以指定一个Properties参数来检索扩展属性。 以下是TechNet文档中的一些示例:
# Retrieve and display the list of all the properties for an ADGroup object Get-ADGroup -Identity Administrators -Properties *| Get-Member # To retrieve the extended properties "OfficePhone" and "Organization" and # the default properties of an ADUser object named "SaraDavis" GetADUser -Identity SaraDavis -Properties OfficePhone,Organization # To retrieve the properties with LDAP display names of "otherTelephone" and # "otherMobile", in addition to the default properties for the same user GetADUser -Identity SaraDavis -Properties otherTelephone,otherMobile | Get-Member
如果你不介意我会推荐你一个工具。
…
我正在使用“Cjwdev软件”中的“AD-Info”从Active Directory中提取信息。 在我的情况下,标准版正在被用来分析AD和生成定制的报告。 在你的情况下,免费版应该可能已经做到了。
如果你跑步
get-adgroup -filter {displayname -eq 'Consultants'} |get-adgroupmember | format-list *
你会看到,第一个地方没有很多的字段/属性。 你想要的不在那里。
distinguishedName : CN=buncha junk,DC=net name : User's name objectClass : user objectGUID : some guid SamAccountName : SAM account name SID : some SID PropertyNames : {distinguishedName, name, objectClass, objectGUID...} PropertyCount : 6
所以,你不能用你正在使用的工具来做你想做的事情。 您可能可以将SID或DN传递给另一个工具。