This script creates Active Directory computer objects from a CSV file and immediately applies domain join permissions and group memberships based on the CSV data. It is meant to standardize how new workstations or servers are created in AD.
- Reads computer definitions from a CSV file.
- Builds computer names based on fields such as site ID and service tag.
- Creates the computer object in the specified OU.
- Adds the computer to one or more AD groups for permissions or targeting.
- Grants a join group full control on the computer object so it can join the domain.
- Writes a transcript log for auditing.
- Can generate a CSV template for you.
-
PowerShell 5.1 or later.
-
Active Directory module:
Import-Module ActiveDirectory
- Permissions to create computer objects in the target OUs and to edit their ACLs.
Common parameters (exact names may differ slightly from this example, update to match your script):
-
-PathPath to the input CSV file. If omitted, the script can prompt with a file selection dialog. -
-GenerateTemplateWhen present, the script generates a sample CSV file (for exampleComputerTemplate.csv) with the required columns and exits. -
-TranscriptPathOptional path for the transcript log. If not supplied, a file such asCreate-ADComputer-YYYYMMDD_HHMMSS.logis created in the current directory.
Adjust this section to match your actual columns. A common layout might look like:
SiteId,ServiceTag,Description,OU,JoinGroup,Groups
ABR1,ABC1234,"Classroom PC 01","OU=Workstations,OU=Education,DC=example,DC=com","Join-Workstations","G-Workstations,G-Physical-Lab"
Typical columns:
SiteId- Site or location code.ServiceTag- Hardware identifier used as part of the name.Description- AD description field for the computer.OU- Distinguished name of the OU where the computer object should be created.JoinGroup- Group that will be granted full control on the computer object for domain join.Groups- One or more security groups (comma separated) that the computer should be added to.
.\Create-ADComputer.ps1 -GenerateTemplateThis creates a sample CSV you can fill out with your own data.
.\Create-ADComputer.ps1 -Path "C:\Temp\computers.csv"The script will:
- Read each row from the CSV.
- Build a computer name from the site and service tag (or according to your naming logic).
- Create the computer object in the specified OU.
- Add the computer to any groups listed in the CSV.
- Grant the join group full control on the object to allow domain joins.
- Write a transcript log.
.\Create-ADComputer.ps1 -Path "C:\Temp\computers.csv" -TranscriptPath "C:\Logs\Create-ADComputer.log"- Consider testing against a lab OU before you run this in production.
- If you change your naming convention or group layout later, you can update the CSV template and reuse the script.