Solved

just remove one group

Posted on 2012-04-03
4
500 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This article will help you understand what HashTables are and how to use them in PowerShell.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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