In order to register an instance to your domain, please apply the following to your Elastigroup settings.
What the script does:
1. Checks if the machine is already member in the domain, if it is the script does nothing
2. Set the DNS server on the network interface (needed to discover the domain)
3. Adds the instance to the domain
4. Restart the machine (for changes to take effect)
Add the following User Data:
$isMember = (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain
$dnsserver = "10.0.0.1"
$domain = "myDomain"
$password = "myPassword!" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\myUserAccount"
$ou = "OU=testOU,DC=domain,DC=Domain,DC=com"
$nic = Get-NetAdapter
Set-DNSClientServerAddress –interfaceIndex $nic.ifIndex –ServerAddresses ($dnsserver)
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -Credential $credential -OUPath $ou
shutdown -r -t 00
Please note these values need to be changed:
$username - just the 'myUserAccount' part
Note: $ou is optional - if not required, delete this line and remove the -ou flag and value from the Add-Computer command.
Note: The script assumes that the instance has only 1 network interface, in case it has more a slight modification is required ( please contact us if you need that as well)