New-ADComputer - Automated Computer Object Creation in AD.txt - Notepad

New-ADComputer - Automated Computer Object Creation in AD

# Import list of computer names from a CSV file into $computerlist (one column, heading = name)
$computerlist=import-csv h:\computers.csv

# Step through each item in the list
ForEach ($computer in $computerlist) {

# Set computername from the info in the CSV file
$computername=$computer.name

# Create the computer in Active Directory using the new-adcomputer cmdlet
New-adcomputer -Name $computername.toupper() -samaccountname $computername.toupper() -path "OU=Test,OU=Users,OU=billiton,DC=bhp,DC=corporate" -Enabled $True -Description "generic test computer account"

}

Back