User Groupmembership removal+ groups are located in child domains

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Richard Diphoorn Richard Diphoorn 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38313
    Profile photo of nidhin ck
    nidhin ck
    Participant

    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
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.