User Groupmembership removal+ groups are located in child domains

Welcome Forums General PowerShell Q&A User Groupmembership removal+ groups are located in child domains

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
2 years, 7 months ago.

  • Author
    Posts
  • #38313

    Participant
    Points: 7
    Rank: Member

    Need to removed user group membership of multiple users whose groups are located in child domains (within forest) . While using below code, getting error for users whose groups are located in child domain than user domain.

    $users = Get-Content c:\users.txt
    foreach ($user in $users){
          $ADgroups = Get-ADPrincipalGroupMembership -Identity $user -Server dc01.nidhin.com | where {$_.Name -ne "Domain Users"}
          Remove-ADPrincipalGroupMembership -Identity "$user" -MemberOf $ADgroups -Confirm:$false 
    }
  • #38373

    Participant
    Points: 26
    Rank: Member

    It would be helpful if you can show the error message?

The topic ‘User Groupmembership removal+ groups are located in child domains’ is closed to new replies.