
With this script, you will be able to set the registry AnnounceFlag to “0x5” on each PDC emulator on your forest
The script performs these steps :
- List all PDC emulator on all domains in the current forest
- Read the current value of the “AnnounceFlag” registry entry
- If it is not “0x5”, the registry is updated
- If the registry is updated, the Windows Time service is restarted
@(([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Domains ) | % { $info = Get-ADDomain -identity $_.name | select DNSRoot,PDCEmulator $dc = $info.PDCEmulator $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $dc) $regKey= $reg.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\W32Time\\Config",$true) $regkey.GetValueNames() | foreach {$regkey.getvalue($_)} write-host $dc ":" $regkey.getvalue('AnnounceFlags') if ($regkey.getvalue('AnnounceFlags') -ne 5) { $regkey.SetValue('AnnounceFlags',5) $service = get-service -ComputerName $dc -Name "Windows Time" Restart-Service -InputObject $service -Verbose $service.refresh() $service } write-host $dc ":" $regkey.getvalue('AnnounceFlags') }
Reference
Windows Time service Tools and settings
AnnounceFlags
Registry path
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config
Version
Windows XP, Windows Vista, Windows 7, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, and Windows Server 2008 R2
This entry controls whether this computer is marked as a reliable time server. A computer is not marked as reliable unless it is also marked as a time server.
0x00 Not a time server
0x01 Always time server
0x02 Automatic time server
0x04 Always reliable time server
0x08 Automatic reliable time server
A value of 5 means 0×04 + 0×01. In common words “Always time server” + Always reliable time server”.
Nice script. Or you can just set it via a GPO and it’s managed forever.
http://www.jhouseconsulting.com/2014/01/10/script-to-create-group-policy-objects-and-wmi-filters-to-manage-the-time-server-hierarchy-1153
Cheers,
Jeremy