I'm trying to create more 'self-service' virtual machines for the developers to use. On of the requirements is after running a script to bootstrap the machine and join it to the domain, that the machine's local domain controller immediately replicates its data (such as the newly registered machine name) back to to the main corporate domain controller.
This should allow a developer to immediately address the machine by DNS name rather than IP address.
The script:
- Interactively capture domain admin credentials
- Joins to domain
- Configure some local server stuff
- Emails a report
The boot strap script is designed to be called interactively by a sysadmin (domain admin) to set up the machine for a developer, but later it will be baked into an unattend.xml.
I've tried the following approaches:
1.Connect via WMI to a domain controller with domain admin credentials and run repadmin there to force replication
This doesn't appear to work because repadmin doesn't like being called over WMI, it claims not to have the permissions due to how it interprets credentials over WMI
$remotesession = new-pssession -computername "localdomaincontroller" -Credential $credential
invoke-command -ScriptBlock {
Repadmin /replicate corporatedomaincontroller localdomaincontroller 'DC=company,DC=com'
} -Session $remotesession
Remove-PSSession -Session $remotesession
2.Run repadmin locally
So I installed repadmin into my server templates but this doesn't seem to work unless you reboot the machine first. Since I want all the tasks launched from a single script this appears not to work.
Start-Process powershell.exe -Credential $credential "Repadmin /replicate corporatedomaincontroller localdomaincontroller 'DC=company,DC=com'"
So can anyone advise, how can I both join a machine to a domain AND force DC replication from a single script?
Best Answer
Assuming that you're not having problems with DNS replication to begin with (have you confirmed this ...? ) :
You will also need to know the source DC (where the DNS record first exists) and target DC (the one being used by the developers) to make sure you're actually replicating the record that you care about.
How to speed up AD integrated DNS zone replication? Server 2008 r2
Per Simon Catlin:
Repadmin doesn't require a server reboot, I have no idea what would lead you to think that it does.