How to change primary dns suffix via vbscript or command line?
The question is straight forward. In a fresh build windows 2008 computer, right click computer and then select properties, then click Change settings->Change->More By default, after refresh installation, Primay dns suffix is empty and option "change primary dns suffix when domain membership changes" is checked. I want to use a vbscript or command line to uncheck the option and then change the dns suffix to corp.ad.root Any suggestion? Thanks
December 2nd, 2010 2:20pm

Hello, what's the reason for doing this? Having a different primary DNS suffix then the domain name that the machine belongs to, is called disjoint namespace and you run into trouble. http://technet.microsoft.com/en-us/library/cc731125(WS.10).aspxBest regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
December 2nd, 2010 4:31pm

Hi, Thanks for posting here. You may refer to the links below , some sample scripts could be found in there. Meanwhile, setting DHCP options is also a way to achieve the goal. http://support.microsoft.com/kb/275553 You could also post you requirement to script forum and get solutions. http://social.technet.microsoft.com/Forums/en/ITCG/threads/ Thanks. Tiger LiPlease remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
December 3rd, 2010 3:18am

I am awared of disjoined dns name space. That is due to the business requirment and this should be support by Windows server as long as this is not applied on DC. Now back to my question. The following procedure can reproduce the issue 1. Install a windows 2008 x64 standard, all using default settings. There is a DNS server hosting DNS domain named corp.org. The DHCP server is configured to use dns domain name as itHQ.ad.org 2. Once the server is boot up after installation, the option "change dns primary dns suffix when domain membership changed" is checked by default. And the primay dns name is empty. 3. Run following script Const HKEY_LOCAL_MACHINE = &H80000002 Call Change_Primary_DNS_Suffix(".","corp.org") Function Change_Primary_DNS_Suffix(strComputer,vPDNS)     On Error Resume Next      Err.Clear     WScript.Echo "Changing primary DNS suffix..."     Dim oReg     Dim strKeyPath,strValueName,vValue     Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _         strComputer & "\root\default:StdRegProv")        strKeyPath = "SYSTEM\CurrentControlSet\services\Tcpip\Parameters"     '///Disable option "Change primary DNS suffix when domain membership changes"      strValueName = "SyncDomainWithMembership"     vValue = 0     oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,vValue          strValueName = "Domain"     vValue = vPDNS     oReg.SetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,vValue          WScript.Echo vbTab & "Disabled option ""Change primary DNS suffix when domain membership changes"". Changed primary DNS suffix to """ & vPDNS & """ at " & Now() & ". Return code:" & Err.Number & "." & Err.Description End Function 4. reboot the server 5. The when try to ping host.itHQ.ad.org or host.corp.org will get error as "ping can not find the host". But if run nslookup agains those names, it could resovle the names without issue. So I am scraching my head here, WHY? Please note: here the server is still a stand alone server. Not join the domain yet. So it has nothing to do with the disjoined dns name space yet. But just the tcp/ip settings. I don't understand why after I changed those two registry key, the ping can not find host which could be resolved in nslookup.
Free Windows Admin Tool Kit Click here and download it now
December 9th, 2010 5:23pm

I found the cause. I should use SetStringValue in the script instead of SetExpandedStringValue in the script. Problem solved.
December 10th, 2010 4:04pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics