Answered by:
Remove user from group

Question
-
Hello everyone,
I need help with a simple powershell command
I have a security group called TestGroup, with 100 member within. I need a command to remove 10 specific users from this group.
I tried constructing the command myself but I got stuck
Here is how far I got:
dsquery group -name TestGroup | dsget group -members | dsrm
Any help will be greatly appreciated.
Friday, April 5, 2013 10:25 AM
Answers
-
dsmod group "GroupDN" -rmmbr "MemberDN"
DN is distinguished Name
_____________
Using powershell active directory module.
import-module activedirectory
remove-adgroupmember -Identity "GroupName" -Member "Username"
Thanks Azam When you see answers please Mark as Answer if Helpful..vote as helpful.
- Edited by mohdazam89 Friday, April 5, 2013 10:57 AM
- Proposed as answer by R Jason Morgan Friday, April 5, 2013 12:36 PM
- Marked as answer by Fady Adel Friday, April 5, 2013 2:00 PM
Friday, April 5, 2013 10:55 AM -
dsquery user -name ADUSERNAME
Thanks Azam When you see answers please Mark as Answer if Helpful..vote as helpful.
- Marked as answer by Yan Li_ Monday, April 8, 2013 5:52 AM
Friday, April 5, 2013 12:30 PM
All replies
-
dsmod group "GroupDN" -rmmbr "MemberDN"
DN is distinguished Name
_____________
Using powershell active directory module.
import-module activedirectory
remove-adgroupmember -Identity "GroupName" -Member "Username"
Thanks Azam When you see answers please Mark as Answer if Helpful..vote as helpful.
- Edited by mohdazam89 Friday, April 5, 2013 10:57 AM
- Proposed as answer by R Jason Morgan Friday, April 5, 2013 12:36 PM
- Marked as answer by Fady Adel Friday, April 5, 2013 2:00 PM
Friday, April 5, 2013 10:55 AM -
Thanks a LOT mohdazam89,
I am using the 1st method, but I dont have the full DN of all members, as they are not in the same container.
Is there a way where I can make the command fetch the full DN from the AD?
Friday, April 5, 2013 11:31 AM -
dsquery user -name ADUSERNAME
Thanks Azam When you see answers please Mark as Answer if Helpful..vote as helpful.
- Marked as answer by Yan Li_ Monday, April 8, 2013 5:52 AM
Friday, April 5, 2013 12:30 PM