I'm trying to remove a security group from a list of systems that I choose (unless I can remove a certain group from an entire OU in AD.)
however I keep getting the following message for every system:
Remove members from group
Do you want to remove all the specified member(s) from the specified group(s)?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
This is my code:
Import-Module ActiveDirectory
$comps=Get-Content "C:\nice\LIST-OF-SYSTEMS.txt"
foreach ($comp in $comps) {
$dns = get-adcomputer $comp
$b = $dns.distinguishedname
Remove-ADPrincipalGroupMembership $b EXAMPLE_GROUP
}