Link to home
Start Free TrialLog in
Avatar of MilesLogan
MilesLoganFlag for United States of America

asked on

Remove an AD group from multiple servers

Hi EE

I have the script below that someone here helped me with to nest a Domain group into the Administrators group into multiple machines .. Would it be as easy as changing ".add" to .remove ? I tried it and it worked but I don't want to run it on 100 servers without confirmation from the experts .

$ErrorActionPreference = "Stop"
GC Servers.txt | %{
$Serv = $_
$domain="MyDomain"
$group = "GroupName"
        Try {
        ([adsi]"WinNT://$Serv/Administrators,group").Add("WinNT://$domain/$group,group")
        "" | Select @{N="Server";e={$Serv}},@{N="Status";e={"Success"}}
        }
        Catch{
        "" | Select @{N="Server";e={$Serv}},@{N="Status";e={"Failed"}}
        }
}
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MilesLogan

ASKER

Thanks for checking Will .. yeah GPO was not an option , too many variables .. it was just a quick temporary fix .