PowerShell: Create Computers from Names in a List

PowerShell: Create Computers from Names in a List

Sometimes I find the need to create 10-20 computers for my AD lab at home, to do this in PowerShell you can run the following command:

Get-Content computers.txt | ForEach-Object { New-ADComputer -Name $_ }

If you want to create the computer objects in an OU other than “Computers”, lets say you want to prestage a number of computer objects for a new department, you could do this:

Get-Content computers.txt | ForEach-Object { New-ADComputer -Name $_ -Path "Specify Path"}

One thought on “PowerShell: Create Computers from Names in a List

  1. { print $array[0] . “n”; }That’ll give you as many copies of $array[0] as there are parts in the array.You can aclcopmish everything you’re doing in this file with:perl -lanwe ‘print $F[0]’ /path/to/your/access_logFor text processing things, it’s often better to use (with no explicit file-opening/-closing) than .Just some tips for someone who might come across this later, as I did.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.