Print View

How to rename a Windows instance and join an Active Directory domain with AWS user data


When deploying an instance from an AMI, it is possible to change the computer name to the instance ID and join a domain in a single step.


The following PowerShell user data can be used to:

- Rename the instance
- Join a domain
- Specify an OU for the computer account

$password = "<password>" | ConvertTo-SecureString -asPlainText -Force
$username = "DOMAIN\username"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
$instanceID = invoke-restmethod -uri
Add-Computer -domainname domain.local -OUPath "OU=Computers,DC=domain,DC=local" -NewName $instanceID -Credential $credential -Passthru -Verbose -Force -Restart


Configuring a Windows Instance Using the EC2Config Service


Amazon Web Services (any)

Created: 18th September 2014
Updated: 18th September 2014

Print View

© 2005-2024 Jamie Morrison