While back, we migrated computer and user accounts to new Active Directory Domain. We wanted all the client computers set the correct Primary DNS suffix, Connection specific DNS suffix and DNS search suffix list. I decided to write a little VBScript that can be added to our current logon script, so whenever user logs in their computer gets the correct DNS suffix values.
I wrote the script to check the current DNS suffix values and change them if not correct. Note: You need to provide correct values for sDNSPrimarySuffix and SDNSSuffixSearchList variables.
Here is the script:
‘******************************************************************************************
‘* This script will add primary DNS suffix and "Connection Specfic DNS suffix search list
‘* into local computer. Change the sDNSPrimarySuffix and sDNSSuffixSearchList strings
‘* to appropriate values
‘*
‘* Author: Anand Venkatachalapathy
‘* Written Date: October 4th 2007
‘******************************************************************************************
Set WshShell = WScript.CreateObject("WScript.Shell")
‘
‘Set Primary DNS Suffix and Search list for domain clients
‘
sDNSPrimarySuffix = "company.com"
sDNSSuffixSearchList = "company.com,corp.company.com,marketing.company.com,europe.company.com"
sDomain = WshShell.RegRead ("HKLMSYSTEMCurrentControlSetServicesTcpipParametersDomain")
If StrComp(lcase(sDomain),lcase(sDNSPrimarySuffix)) <> 0 Then
‘Change the Primary DNS Suffix name
WshShell.RegWrite "HKLMSYSTEMCurrentControlSetServicesTcpipParametersDomain", sDNSPrimarySuffix, "REG_SZ"
WshShell.RegWrite "HKLMSYSTEMCurrentControlSetServicesTcpipParametersNV Domain", sDNSPrimarySuffix, "REG_SZ"
WshShell.RegWrite "HKLMSYSTEMCurrentControlSetServicesTcpipParametersSyncDomainWithMembership", 1, "REG_DWORD"
‘Change the DNS Suffix Search List
WSHShell.RegWrite "HKLMSystemCurrentControlSetServicesTCPIPParametersSearchList", sDNSSuffixSearchList, "REG_SZ"
Else
WScript.Echo "This computer is already set to current DNS Primary Suffix: " & sDomain
End If
‘End of DNS Suffix Script
‘
‘*******************************************************************************************
Admiring the time and energy you put into your website and detailed information you
provide. It’s nice to come across a blog every once in a while that isn’t the same outdated
rehashed information. Fantastic read! I’ve saved your site and I’m adding your RSS feeds to my Google account.