Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Script to delete a user

Posted on 2011-02-11
2
Medium Priority
?
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Let's recap what we learned from yesterday's Skyport Systems webinar.
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

610 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