Answered by:
Change Primary DNS suffix of this computer

Question
-
Hello,
im preparing windows image for deployment, and a part of my script add newly created computer to domain.
Before first restart, i need to modify settings which u can do via GUI "Right Click My Computer>Properties>Advanc
ed System Settings>Computer Name>Change>More" I require to change DNS suffix to srv.domain.com and uncheck "Change primary DNS suffix".
Part of my setupcomplete.cmd (well the script is calling MyScript.ps1) is..
$ADParams = @{ DomainName = "domain.com" OUPath = "myOU" NewName = "Server1" Credential = $cred } Add-Computer @ADParams get-netadapter | set-dnsclient -connectionspecificsuffix srv.domain.com -registerthisconnectionsaddress:$false restart-computer
.. which, i believed, will join my newly created computer to domain and change this DNS suffix.
But it changed Connection-specific DNS suffix instead of Primary Dns Suffix (well, i used wrong cmdlet obviously and changed something i didnt want to change).
I know it could be changed via GPO .. but I want to do this via PS. Any tips?
- Edited by Mekac Friday, March 9, 2018 12:40 PM
Friday, March 9, 2018 12:39 PM
Answers
-
Hi,
According to your description, the above script actually changes the DNS suffix in the network adapter, the following screenshot for your reference:
While the DNS suffix settings based on the screenshot above are stored in the registry, you can modify them by using the following command:
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name 'NV Domain' -Value srv.domain.com Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name SyncDomainWithMembership -Value 0 # Restart-Computer
If you need further help, please feel free to let us know.
Best Regards,
AlbertPlease remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com- Marked as answer by Mekac Monday, March 12, 2018 7:51 AM
Monday, March 12, 2018 4:10 AM
All replies
-
Hi,
According to your description, the above script actually changes the DNS suffix in the network adapter, the following screenshot for your reference:
While the DNS suffix settings based on the screenshot above are stored in the registry, you can modify them by using the following command:
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name 'NV Domain' -Value srv.domain.com Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name SyncDomainWithMembership -Value 0 # Restart-Computer
If you need further help, please feel free to let us know.
Best Regards,
AlbertPlease remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com- Marked as answer by Mekac Monday, March 12, 2018 7:51 AM
Monday, March 12, 2018 4:10 AM -
Yeah, I found the registry example yesterday .. will test it asap. ThanksMonday, March 12, 2018 7:51 AM