Solved

Powershell - New computers to AD Domain

Posted on 2013-05-21
7
309 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
  • 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
Are your AD admin tools letting you down?

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.

 

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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A safe way to clean winsxs folder from your windows server 2008 R2 editions
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now