I was recently asked to add a certain Active Directory group to a few dozen computers. Using Group Policy and Restricted Groups was not an option here, since there were already other users and groups in the Administrators group. That triggered me to write up a script in PowerShell which could do this for me.
The script is available here: Technet Gallery: Set-ADAccountasLocalAdministrator.ps1
To set an AD Group as a Local Administrator the script can be executed as follows:
.\Set-ADAccountasLocalAdministrator.ps1 -Computer 'Server01,Server02' -Trustee HRManagers |
.\Set-ADAccountasLocalAdministrator.ps1 -Computer 'Server01,Server02' -Trustee HRManagers
It is also possible to run this script with a plain text file containing a list of computer names:
.\Set-ADAccountasLocalAdministrator.ps1 -InputFile C:\ListofComputers.txt -Trustee User01 |
.\Set-ADAccountasLocalAdministrator.ps1 -InputFile C:\ListofComputers.txt -Trustee User01
Like this:
Like Loading...