Bulk create computer accounts with PowerShell

Hi All ,

I recently had a requirement to pre-create 30 computers accounts in Active Directory for computers that had not yet been domain joined.

To do this I used a script to generate the computer accounts. Using this script, you can pull the computer names from a CSV file and create them in a specific OU automatically.

1) Create a new CSV file in excel with a column called ‘computer’ and a list of computer names. Save the CSV in location accessible by your domain controller.

2) Determine the distinguished path for the OU that the computer accounts will be created. If you have a similar computer you can get this by running ‘Get-ADCompuer “DESKTOP01” | fl’ and looking for the ‘DistingushedName’ attribute.

3) Run the following in PowerShell on your domain controller. Ensure that you have the OU and CSV variables set correctly as above.

Import-Module ActiveDirectory

$CSV=‘C:path-to-csvComputers.csv’

$OU=‘OU=Devices,DC=risualblogs,DC=com’

Import-Csv -Path $CSV | ForEach-Object { New-ADComputer -Name $_.Computer -Path $OU -Enabled $True}

Hope this helps

About the author