Get-ADGroup -Filter * -SearchBase 'OU=Group,DC=gawcap,DC=com,DC=cn' | ForEach-Object { $groupName = $_.Name Get-ADGroupMember -Identity $groupName | Select-Object @{Name = 'GroupName'; Expression = {$groupName}}, Name | Group-Object GroupName | Select-Object @{Name = 'GroupName'; Expression = {$_.Name}}, @{Name = 'Members'; Expression = {($_.Group.Name | Out-String).Trim()}} } | Export-Csv -Path C:\membership.csv -NoTypeInformation
Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact
tnmff@microsoft.com
联系客服