Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Add multiple security groups on multiple servers
# This script will add multiple groups on multiple serevrs
# Make sure you have one server in each row in the servers text file
# you must have administrator access on the server
$ServersList = "D:\ServersList.txt"
$ServerNames = get-content $ServersList
$UserGroupFilePath = "D:\SecurityGroup.txt"
$UserGroupList = get-content $UserGroupFilePath
$DomainName ="Enter your ___domain name here"
foreach ($name in $ServerNames)
{
$localAdminGroup = [ADSI]("WinNT://$name/Administrators")
# Add all the groups in text file to the current server
foreach ($UserGroupName in $UserGroupList)
{
$AdminsG = [ADSI] "WinNT://$DomainName/$UserGroupName"
$localAdminGroup.Add($AdminsG.PSBase.Path)
Write-Host "Adding" $AdminsG.PSBase.Path "to" $name
} # End of User Group Loop
} # End of Server List Loop
Remove multiple security groups on multiple servers
# This script will delete multiple security groups on multiple servers
# Make sure you have one server in each row in the servers text file
# you must have administrator access on the server
$ServersList = "D:\ServersList.txt"
$ServerNames = get-content $ServersList
$UserGroupFilePath = "D:\SecurityGroup.txt"
$UserGroupList = get-content $UserGroupFilePath
$DomainName ="Enter your ___domain name here"
foreach ($name in $ServerNames)
{
$localAdminGroup = [ADSI]("WinNT://$name/Administrators")
# Add all the groups in text file to the current server
foreach ($UserGroupName in $UserGroupList)
{
$AdminsG = [ADSI] "WinNT://$DomainName/$UserGroupName"
$localAdminGroup.remove($AdminsG.PSBase.Path)
Write-Host "remove" $AdminsG.PSBase.Path "to" $name
} # End of User Group Loop
} # End of Server List Loop