Solved

Powershell - New computers to AD Domain

Posted on 2013-05-21
7
308 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

The problems with reply email signatures

Do you wish that you could place an email signature under a reply? Well, unfortunately, you can't. That great Exchange/Office 365 signature you've created will just appear at the bottom of an email chain. What a pain! Is there really no way to solve this? Well, there might be...

Join & Write a Comment

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This article will help you understand what HashTables are and how to use them in PowerShell.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

758 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

23 Experts available now in Live!

Get 1:1 Help Now