To use it, download it, unblock the file, run it in Powershell_ISE for example to load the function, and use it as in:
Add-Admin -ComputerName V-2012r2-vbr1 -NewAdmin Sam77
creates a new user ‘Sam77’ on computer ‘v-2012r2-vbr1’ and makes member of the local Administrators group.
You can add many admins to many computers in the same line:
Add-Admin -ComputerName V-2012r2-vbr1,NoThere,V-2012R2-G2A -NewAdmin Sam8,Sam88,Sam17 -NewAdminPassword New33One!!
The script leaves a log file showing same messages displayed at the console (without the colors of course):
This script automates the task of creating a local admin account on many computers.
The script can be downloaded from the Microsoft TechNet Gallery
As usual the script leaves a log file on the same folder where it runs. It lists the steps taken and any error messages encountered.
The script works even if Script Execution Policy is Restricted on the target computers.
The script will fail if the password entered for the new local admin account does not meet the minimum password requirements on the target computers.
Word of caution: the new admin account password is saved in the log file which is created in the same folder where the script runs. This is a clear text file. It’s advisable to delete that log file, encrypt it, or move it to a secure folder.