Aug 25 2023 06:37 AM - edited Aug 25 2023 06:46 AM
I am trying to remove users from a group using PS but it will only allow me to remove users in that domain and not from other domain within the forest, (user not found error for other domain within forest) This is universal group and have members from other domain. can someone help me update script to remove users from all domains with in forest. This is a Bulk operation.
something i found, but need fine tuning
$DC_In_Root = (Get-ADDomain us.contoso.com).PDCEmulator
$DC_In_Default = (Get-ADDomain eu.contoso.com).PDCEmulator
$Group = "Test1234"
$Users = Import-Csv ".\Users.csv"
ForEach ($user in $Users){
$Default_Domain_User = Get-Aduser $user -server $DC_In_Default
Remove-ADGroupMember -Identity $Group -Members $Default_Domain_User -server $DC_In_Root
}
Aug 26 2023 12:44 AM
Aug 26 2023 05:45 AM