Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

Powershell - New computers to AD Domain

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
chgl
Asked:
chgl
  • 4
  • 3
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
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
 
chglAuthor Commented:
thank you very much sedwick, what does gc mean and the % before the {
0
 
Meir RivkinFull stack Software EngineerCommented:
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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
chglAuthor Commented:
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
 
Meir RivkinFull stack Software EngineerCommented:
yes.
0
 
chglAuthor Commented:
the txt file does it have to include commans, e.g computer01, computer02, etc??
0
 
chglAuthor Commented:
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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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