Importing staff from the Universal security group to notepad or Excel

lianne143
lianne143 used Ask the Experts™
on
Hi

I have an ALL Staff Universal security group, which we use for sending email for ALL Staff.

Within this ALL Staff Universal security group, there are other departmental mail groups added as well. I would like to have the list of all users who are member of this ALL Staff Universal security group

Is there a way of exporting all the members to a notepad or excel.

Any help will be great.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Simple using PowerShell:

Import-Module ActiveDirectory
Get-ADGroupMember -identity  "Group Name"  -recursive | select Name,mail | Export-csv -path members.csv -NoTypeInformation

Open in new window


HTH
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
If you need to know from which nested group the membership in the Universal group is coming from, try this:
Function Get-ADGroupMemberRecursive {
[CmdletBinding()]
Param(
	[Parameter(ValueFromPipeline=$true)]
	$Identity,
	[string[]]$Property
)
	Begin {
		$splat = @{}
		If ($Property) {$splat['Property'] = $Property}
	}
	Process {
		Get-ADGroupMember -Identity $Identity | ForEach-Object {
			If ($_.objectClass -eq 'User') {
				Get-ADUser -Identity $_ @splat | Select-Object -Property @{n='Group'; e={$Identity.Name}}, *
			} ElseIf ($_.objectClass -eq 'Group') {
				Get-ADGroupMemberRecursive -Identity $_ @splat
			}
		}
	}
}

Get-ADGroup -Identity "ALL Staff" |
	Get-ADGroupMemberRecursive -Property Mail |
	Select-Object Group, Name, SamAccountName, Mail, DistinguishedName |
	Export-Csv -Path C:\temp\members.csv -NoTypeInformation

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial