Amazon Web Service (AWS): Script to add Windows Machine to Domain (devops)

When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts. You can pass two types of user data to Amazon EC2. The below script can be used to add these servers to domain automatically.

<powershell>
Set-ExecutionPolicy -executionpolicy unrestricted -Force -verbose
$user = "contoso\_sys_joincomputer"
$pass = "********" | ConvertTo-SecureString -AsPlainText -Force
$DomainCred = New-Object -TypeName System.Management.Automation.PSCredential ($user, $pass)
Add-Computer -NewName COMPUTERNAME -DomainName contoso.com -Credential $DomainCred -Restart
</powershell>

Leave a Reply

Your email address will not be published. Required fields are marked *