Get members of multiple ad groups and delete them from another - groups can have more then 5000 entries

Hello everyone,

first of all im not really deep into powershell so i need some help for a tricky task for me.
I want to get the users of a list of ad Groups (not more then 2-4 diff.) AD groups, also nested members, and kick out the duplicates.
But the groups might have over 5000 entries and I am not allowed to adjust the size limit.
I know that it works somehow with LDAP queries without Get-AdGroupMembers.
After that I want to remove the list of users from a certain group.

I would be very glad if you could help me and as for that im learning still PS it would be nice to not shorten the language that i can understand it.

Alexander,
Welcome to the forums.

Why is that? It doesn’t make sense to do a certain task without the right tool for it.

That doesn’t make sense or it doesn’t work the way you explained it. When you list all members including members of nested groups and trhere are duplicates where do you know from which group you have to delete them?

PowerShell.org is not a free script shop. We can help with code you wrote by yourself but we do not write ready to use code on request.
So … what have you tried so far? Please show your code.

1 Like

Hello i want to get all Members of a list of Groups inclusive the nested Groups and then this list of Members cleaned from duplicates. Not already removing them from this Groups. After this i want them remove from a other Group.

The easiest way to limit a list of objects to the unique onces is to use Select-Object.

For example:

Get-Process
# vs
Get-Process | Select-Object -Unique