Solved

Powershell - New computers to AD Domain

Posted on 2013-05-21
7
312 Views
Last Modified: 2013-05-30
Hi guys,

I have quite a few computers that I need to add to the domain, is there a way of automating this via powershell?

thank you in advance,
k
0
Comment
Question by:chgl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39183705
put all the computers names in a file, one on each line and run this powersehll script:
gc c:\temp\servers.txt | %{
$domain = "myDomain"
$password = "myPassword!" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\myUserAccount" 
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -ComputerName $_ -DomainName $domain -Credential $credential
}

Open in new window


from http://community.spiceworks.com/scripts/show/1540-join-computer-to-domain-with-powershell-one-click-method
0
 

Author Comment

by:chgl
ID: 39183741
thank you very much sedwick, what does gc mean and the % before the {
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39183745
gc is alias of get-content, and % before { equals to foreach when u loop the pipe results.
for example when u want to loop through lines in file:

gc c:\myfile.txt | %{
}

Open in new window


equlas to:

get-content c:\myfile.txt | foreach-object{
}

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:chgl
ID: 39183746
ohh right thank you :)

will this script bind the computer to the active directory domain so that users can log in with their credentials?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39183755
yes.
0
 

Author Comment

by:chgl
ID: 39183945
the txt file does it have to include commans, e.g computer01, computer02, etc??
0
 

Author Comment

by:chgl
ID: 39183954
are you sure this would work with xp and windows 7 machines? becuase i dont see how the logon to domain on the drop down menu will appear on the log on screen??? should there be some sort of remoting in order to bind to active directory??
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question