Solved

just remove one group

Posted on 2012-04-03
4
495 Views
Last Modified: 2012-04-03
I am trying to remove one group from a list of users. Can you guys tell me the best place to enter this in the script, thanks

names = Get-Content C:\textfiles\listofusers.txt

foreach ($name in $names)
{
$name | get-qadmemberof | Remove-QADGroupMember -Member $name
0
Comment
Question by:techdrive
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
pony10us earned 500 total points
ID: 37801915
http://ss64.com/ps/remove-qadgroupmember.html

names = Tet-Content D:\textfiles\listofusers.txt
foreach ($name in $names)
{
$name | remove-QADGroupMember 'CN=group,OU=ou,DC=dc,DC=com' -member $name
}

The get-qadmemberof is to get a list of members in a group so shouldn't be needed if you are working from a list (c:\textfiles\listofusers.txt) that you already know are members of the group
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 37801975
In its simplist form you would use.....

Get-Content C:\textfiles\listofusers.txt | remove-QADUser "GroupName"
0
 
LVL 26

Expert Comment

by:pony10us
ID: 37802026
@Neilsr: is "remove-QADUser" something new?  I am only aware of these options for QADUser:

 Get-QADUser           Retrieve users that match specific conditions
 Set-QADUser           Modify attributes of a user account
 New-QADUser           Create a new user account
 Enable-QADUser        Enable a user account
 Disable-QADUser       Disable a user account
 Unlock-QADUser        Unlock a user account
 Deprovision-QADUser   Deprovision a user account in AD

I have seen this one to remove all but the primary group from a user:

Get-QADUser $_.EmpID | Remove-QADMemberOf -RemoveAll


EDIT:  Just thought about this reply some more and got to thinking.  I was not attempting to be difficult here.  I was simply asking to see if it was something I wasn't aware of thereby providing me with another learning opportunity.
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 37802352
Sorry was answering two questions. Your correct in that it's not qaduser, it should have read.

Get-Content C:\textfiles\listofusers.txt | remove-QADGroupmember "groupname"
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

17 Experts available now in Live!

Get 1:1 Help Now