Solved

just remove one group

Posted on 2012-04-03
4
506 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
[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
  • 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

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
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

707 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