Remove a particular group from List of users

Hi Readers,

I have came acros a situation where I have to remove a group from thosand of users.

Thanks to Quest Active Directory Mangement roles 🙂

Install these on your machine & below is the small script that takes input from CSV file(Columns in CSV file—> group, username)

for execution : Script.ps1 csv file

# import csv file

$data = import-csv $args[0]

 #Check if usr belogs to group in csv

 foreach ($i in $data)

{

$grp=$i.group

$Can = “CN=$grp”

$user=get-qaduser $i.username

 

if (($user.memberof -like “$Can,*”))

{

write-host “$user is a member & will be removed from Enterprise vault group”

 remove-qadgroupmember $grp $user  }

}

2 thoughts on “Remove a particular group from List of users

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s