Using GUID to Remove member from AD Group. RRS feed

  • Question

  • I saw many examples that allows removal of members from AD Group however, after going through the documentation of Microsoft I came to know that ObjectGUID is also usable for performing the same operation. So, if I have the GUID of Group & GUID of different members that I want to remove how do I perform operation in power shell script? 

    I tried doing this but it didn't work.

    $GroupGUID = 'a3d65150-1739-4cc7-80d2-7b97c76b0aff'
    Get-ADGroupMember -Identity $GroupGUID  |
        Where-Object {$_.ObjectGUID -eq '8a3fab53-4c8b-483d-89f0-e26de236a627'} |
        ForEach-Object {Remove-ADGroupMember $GroupGUID $_ -Confirm:$false}

    Is it suppose to work both the GroupGUID & ObjectGUID are unique for Ad Groups & AD Users in the Active Directory Domain.

    • Edited by Nikul Vyas Monday, June 17, 2019 9:01 PM
    Monday, June 17, 2019 8:08 PM

All replies

  • Remove-ADGroupMember -Identity $groupid -Members $objectid

    Above command seems to be working for me where $groupid and $objectid are the variables where GUIDs are stored, what was the error that you are getting while performing the operation? 
    Friday, June 28, 2019 7:17 AM