当我跑:
get-adgroup -filter {displayname -eq’groupname’} | get-adgroupmember | format-table name,surname,givenname,officephone
如果你真的喜欢单行:
原文链接:https://www.f2er.com/windows/366979.htmlGet-ADGroup -Filter {displayName -eq 'groupName'} | Get-ADGroupMember |Foreach-Object {Get-ADUser -Identity $($_.SID) -Properties name,sn,givenName,otherTelephone} | Format-Table name,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,otherTelephone