Import AD groups from csv and export their members
Hello All,
Having a bit of an issue doing this with bulk import. No issues with running Get-ADGroupMember on a single group but with import... I want to pull my hair out. Not sure if I need to create a custom object or what but I need to import a csv with say 100 groups
and export their members. The issue that I am having is that on the export... I need to have the group name so I know what group theyre members of. Also, I need to get the nested groups (not a recursive to see the nested groups members but the group object
itself) as well as any orphaned SIDs.
I have been researching and testing for weeks... at my wits end.. please help!
September 2nd, 2015 6:35pm
You need to post your script with any error messages.
September 2nd, 2015 7:18pm
This is the only one that I have gotten to work but as you can probably tell... the export doesn't show the groups name that they are members of
Import-Csv {PATH} |
% {
Get-ADGroupMember -Identity $_.groupName |
select name, objectClass } |
Export-Csv {PATH} -NoTypeInformation
September 2nd, 2015 7:33pm
Also, I can't figure out how to identify groups members that are orphaned SIDs. Furthermore, how to remove SIDs from group membership (I know a bit in the weeds) but still an issue... sigh
September 2nd, 2015 10:00pm
Here's an example you can play with that will show you a method of adding the group name to the export:
Get-ADGroup -Filter "Name -like 'Test Group *'" | ForEach {
$groupName = $_.Name
Get-ADGroupMember -Identity $_ | Select @{N='GroupName';E={$groupName}},*
} | Export-Csv .\groupMemberships.csv -NoTypeInformation
September 2nd, 2015 10:02pm
working with your example... i was able to put this together (which after testing, gets me 90% of the way there)
Import-Csv {PATH} |
% {
$GroupName = (Get-ADGroup $_.groupName).name
Get-ADGroupMember -Identity $_.groupName } |
select @{N='Group';E={$GroupName}}, name, objectClass |
Export-Csv {PATH} -NoTypeInformation
The only thing that I am missing is the ability to include orphaned SIDs that are members of the groups. Is this possible?
September 3rd, 2015 7:38am