?
Solved

just remove one group

Posted on 2012-04-03
4
Medium Priority
?
507 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

801 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