I’d like to create a Task that changes the registry based on IP address (different subnets go to different time server).
I’d like something like, If IP starts with 10.10 and ntpserver /= SERVERNAME from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters and type /= ntp from key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
parameter “SERVERNAME” = “{(if (exists addresses whose (it as string starts with “10.10”) of adapters of network) then “TimeServer1” else if (exists addresses whose (it as string starts with “10.11”) of adapters of network) then “TimeServer2” else “DefaultTimeServer”)}”
regset “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters” “ntpserver”="{parameter “SERVERNAME”}"
regset “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters” “type”="NTP"
waithidden cmd.exe /C net stop w32time
waithidden cmd.exe /C net start w32time
You will need to modify/expand the relevance that determines the servername based on the IP… Does that get you closer to what you were looking for?