Link to home
Start Free TrialLog in
Avatar of NetRock6
NetRock6Flag for Canada

asked on

Setting DNS Suffix in Windows 10

Hi ..

Using powershell how can i change DNS suffix name globally not only for one network adapter.
Thanks
Avatar of Matt Minor
Matt Minor
Flag of Canada image

Use the Set-DNSClientGlobalSetting cmdlet as per the MS Article found here: https://docs.microsoft.com/en-us/powershell/module/dnsclient/set-dnsclientglobalsetting?view=win10-ps

This should allow for changing the suffix at a global level, non-specific to network interface.
You need to use GPO for that

use GPO and set 1st suffix as your AD domain and later add other suffixes as you want, latch this policy to domain level and it will take care of all machines

Policy setting: computer configuration\administrative templates\network\dns client and locate dns search suffix list and add there all with comma seperated
Avatar of NetRock6

ASKER

The cmdlet is not working in Windows 10 using the following example:
Set-DnsClientGlobalSetting -SuffixSearchList @("corp.contoso.com")

Open in new window

I need to script the process and cannot use AD.

Thanks.
The command works fine for me on Win10, though I got a permission error at first because I hand't launched my PS console with elevated privileges.

Try executing the command on a client, run powershell as administrator first. If the command works, you should be fine to run in a script provided the script is run with sufficient privileges.
The command working perfectly on my lab machine

did you open powershell with run as administrator?
Certainly, with administrator privilege and It returns no errors... Do you guys reboot after running the cmdlet....
When you execute  as administrator:
Set-DnsClientGlobalSetting -SuffixSearchList @("corp.contoso.com")

Open in new window


If you then execute:
Get-DnsClientGlobalSetting

Open in new window


is "Corp.contoso.com" listed?
User generated image
I did not have to restart for this to apply. Once this script is successfully executed, you can go into the properties of a network interface and verify that the specified suffix is present.

User generated image
yes it is listed. but I do not see it at the attached capture.
CaptureSuffix1.PNG
The attached screen shot is for primary dns suffix, this is normally set by your ISP DHCP server if machine is in workgroup or it can be primary ad domain suffix if machine iss ad joined
What you have added is search list and it won't list there

What is your requirement exactly
Changing the primary DNS suffix, excat same as the attached file
This is what u r attempting

But may i know reason for same
Primary dns suffix is automatically assigned to machine when you join machine to domain
You may chage it through screen shot you posted, its purpose is to append primary dns suffix for any single label host name resolution

For example once you added domain.local as primary dns suffix, if you ping server1, client will send request to dns server as serevr1.domain.local and DNS server will check if server1 is available with primary dns zone (domain.local) and if available you will get ping response.

Is this you wanted to do?

OR

you wanted to set dns suffix search list with domain.local as 1st entry and domain.com, domain.net as secondary and teritory entries respectively?
Now when you ping server1, 1st client will send query to dns as server1.domain.local, if dns don't find any record, client will send serevr1.domain.com and dns will check if he have any record associated with domain.com zone, if not, client will send query as server1.domain.net and if server found entry in domain.net zone, you will get that response

what you wanted to do?
I need to change the primary DNS suffix value in the screen shot....
As stated above, from screen shot you posted change it, close all dialogue boxes one by one and reboot the machine
@Mahesh,
Are you kidding...!!!?????
Doing this on over 100 PCs...
Where did you mentioned that you need to change this in bulk????

Will check cmdlet to change primary dns suffix and post if worked
Kindly, read my question...it is clearly asking for "PowerShell"...
I found no cmdlet... capable of doing this. I think we need to create a custom module
ASKER CERTIFIED SOLUTION
Avatar of Mahesh
Mahesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great... Thanks for your help