Solved

Script to delete a user

Posted on 2011-02-11
2
299 Views
Last Modified: 2012-05-11
I have a very small script that pulls the group membership for a user:
dsget user UserDN -memberof

What I wanted to do was pull the results of that script, which are the group DNs, into some type of script that would remove the user from those groups.  This command will remove the user from the group.  But how would I get just one script to do all of it?
dsmod group GroupDN -rmmbr UserDN

Any suggestions would help.
0
Comment
Question by:sedberg1
2 Comments
 
LVL 8

Expert Comment

by:Toxacon
ID: 34873535
I recommend using PowerShell (and PS scripts), which is good for cases like this.
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 34873815
Since Toxacon mentioned Powershell you can do this using the Quest AD cmdlets

$user = "USERNAME"
get-qadmemberof $User | %{
Remove-QADGroupMember $_ $User
}

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now