Author Posts

April 27, 2016 at 11:38 am

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 
}

April 28, 2016 at 10:54 pm

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