What it does:
1. Pulls the administrators in the local administrators group
2. Searches the administrators for any names starting with the domain (either FQDN or just DN)
3. Creates a new text file with the names with the DN
4. Attempts to delete the accounts listed in the text file (which is the problematic piece)
5. Looks for a specified local account and creates it if it is missing
6. Adds specified account to the local administrators group
Code: Select all
FOR %%L IN ("%_localadmins%") DO ((net localgroup administrators %%L /delete ) && echo %%L)