• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

Creating Computers with Powershell

I am wanting to create computers in AD automatically by prompting the user for a prefix, a starting number, and how many new computer to create.

How can I do this?
Joseph Moody
Joseph Moody
1 Solution
Are you talking about creating computer accounts in AD? Can you give an example on how you want to do it?

In PowerShell you can use New-ADComputer command to create computer accounts..
Import-Module ActiveDirectory
$prefix = Read-Host "Enter prefix"
try { [int]$startnumber = Read-Host "What's the starting number?" -ea "Stop"}
catch {"Need to enter a number"; break}
try { [int]$number = Read-Host "How many computer accounts do you want to create?" -ea "Stop"}
catch {"Need to enter a number"; break}
ForEach ($i in ($startnumber..($startnumber + $number -1)))
  $compName = $prefix + $i
  New-ADComputer -name $compName

Open in new window

Joseph MoodyBlogger and wearer of all hats.Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now