-
-
Save quanticc/3cb3c9c4f4ccb2f414cc9893bcab80b9 to your computer and use it in GitHub Desktop.
Windows Server AD Deployment Settings on AWS (DNS, Domain join)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Joins new Windows server to a Windows domain on AWS | |
.DESCRIPTION | |
Sets local DNS entries to DNS server(s) by IP (Set-DnsClientServerAddress) | |
Enables "Use this connection's DNS suffix in DNS registration" (Set-DnsClient) | |
Appends domain DNS suffix (WMI) | |
Adds server to domain in specified OU and renames server (Add-Computer) | |
.EXAMPLE | |
Log on to new server | |
Move/Copy this script to new server | |
Open script in ISE/editor | |
Modify target OU path for new server | |
Save script as .ps1 | |
Run as admin | |
Enter "ethernet" interface index | |
Enter IP address(es) of target environment DNS servers | |
Enter domain name of target domain | |
Enter desired computer name for the new server | |
Enter credentials of Enterprise/Domain admin on target domain | |
Run Restart-Computer | |
#> | |
Get-DnsClient | |
$id = Read-Host "Enter the Interface Index (ex., 7, 3, etc.)" | |
$dnsIP = Read-Host "Enter the IP address(es) of the primary DNS server (Set-DnsClient) [10.0.1.12, 10.0.1.13]" | |
$domain = Read-Host "Enter the domain name (ex., corp.company.com, contoso.local, etc.)" | |
$name = Read-Host "Enter the new computer name (ex., SVR1, DNS01, etc.)" | |
Set-DnsClientServerAddress -InterfaceIndex $id -ServerAddresses $dnsIP | |
Set-DnsClient -InterfaceIndex $id -UseSuffixWhenRegistering:$true | |
$suffixes = 'us-east-1.ec2-utilities.amazonaws.com', 'ec2.internal', $domain | |
$class = [wmiclass]'Win32_NetworkAdapterConfiguration' | |
$class.SetDNSSuffixSearchOrder($suffixes) | |
# Modify OU path before run | |
Add-Computer -DomainName $domain -OUPath "OU=servers,DC=corp,DC=company,DC=com" -NewName $name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment