PowerShell gurus - me again!

Soldato
Joined
28 Sep 2008
Posts
14,158
Location
Britain
Chaps,

I need to remove a large number of users from multiple groups. ie, for 100 users that are in 6 groups (all 100 users are in the same 6 groups), i need to remove them from those 6 groups.

I'm thinking something based on OU (as all 100 users are in the same OU).

Maybe there's a way that doesn't involve PowerShell??
 
Associate
Joined
14 Dec 2011
Posts
434
Here's 1 way: http://technet.microsoft.com/en-us/library/ee617242.aspx

So you could create 2 files containing the user list and group list, read them into the powershell script and then do a nested loop. This would make your script reusable in the future (all you would need to do is edit the list files for users and groups).

Example pseudo code:
Code:
foreach (group)
{
	foreach (user)
	{
		Remove-ADGroupMember <user> <group>
	}
}

Of course, remember the -whatif parameter for testing it out.
 
Back
Top Bottom