2

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?

5
  • Depends on your DNS. Is it AD-integrated, or not?
    – mfinni
    Jul 30, 2014 at 16:53
  • yes, it's AD integrated :(
    – Deku-shrub
    Jul 30, 2014 at 16:58
  • Is a remote session (PowerShell Remoting or WinRM), an option? Seems like having your script create a remote session and then calling repadmin would side-step your WMI/credentials issues. Jul 30, 2014 at 17:03
  • @HopelessN00b that's exactly what I was doing in #1
    – Deku-shrub
    Jul 31, 2014 at 8:58
  • @ChrisMonteiro: Why not just enable site link notification between their site and the corporate site?
    – Greg Askew
    Jul 31, 2014 at 12:22

1 Answer 1

2

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:

I've used this to do pretty much the same thing. Don't replicate everything, you only need to replicate the dnsDomain partition (i think the DN is dc=domaindnszones,dc=yourdomain,dc=co,dc=uk).

Example of repadmin:

%SystemRoot%\System32\repadmin.exe /replicate <target_dc> <source_dc> DC=DomainDnsZones,DC=domain,DC=co,DC=uk

Repadmin doesn't require a server reboot, I have no idea what would lead you to think that it does.

1
  • All I know is that repadmin as per #2 isn't working immediately after joining to a domain, and after a reboot it does work
    – Deku-shrub
    Jul 31, 2014 at 8:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .