Active Directory
Adding Computer Accounts to AD in Bulk

Adding Computer Accounts to AD in Bulk

Table of Contents

During larger deployments, it can be very timeconsuming to create accounts for new computers in Active Directory. While this is not an issue if you need to deploy 510 workstations, it becomes very challenging when there are 100200 workstations.

In this scenario, it is much more efficient to add computer accounts to Active Directory in bulk. PowerShell is perfect for this task.

Step 1 – Create CSV with list of computer names.

Create CSV file with list of computers to be added to Active Directory. Sample CSV file can be downloaded here. Please note that first row contains header NAME.

Step 2 – Create CSV file with list of security groups.

Additionally, we will create a CSV file that lists all the security groups to which those computers should be members of. Template can be downloaded from here.

Step 3 – PowerShell Script.

Place both CSV files in the same directory and run following script:

				
					Import-Module ActiveDirectory

# Import list of Computer Names and Security Groups
$PCList = Import-Csv -Path .\Computers.csv
$GroupsList = Import-Csv -Path .\Groups.csv
$OUPath = "OU=WORKSTATIONS,OU=DEVDOMAIN,DC=devdomain,DC=co,DC=uk"

# Create Computer Account in Active Directory
foreach ($PC in $PCList.NAME) {
    Write-Host $PC
    New-ADComputer -Name $PC -SAMAccountName $PC -Path $OUPath -Enabled $true

# Add Computer to Security Groups   
    foreach ($group in $GroupsList.GROUPS) {        
        Add-ADGroupMember -Identity $group -Members $PC$ -ErrorAction SilentlyContinue
        }
    }

				
			

Adding computer accounts to Active Directory in bulk is a great way to save time and resources when you need to deploy hundreds of workstations. This process is simple and straightforward and can be done in a few steps. By creating a CSV file and using the appropriate PowerShell script, you can computer accounts to Active Directory in no time. This will save you a lot of time and resources and make your deployments much easier.

Share This Post

Leave a Reply