question

FabrizioRamos-5486 avatar image
0 Votes"
FabrizioRamos-5486 asked emilemilmammadli-6480 commented

How to add dns record only to computers with static ip excluding dhcp computers via gpo

Hello everyone

I need to modify the dns registers via gpo only to the computers that have a static ip excluding the computers that are found via DHCP.
It must be in the following order
First: IP 1.1.1.1
Second: IP 1.2.3.4
Third: IP 2.2.2.2

Current Scenario:
First: IP 1.2.3.4
Second: IP 2.2.2.2

thanks

windows-active-directorywindows-group-policywindows-dhcp-dns
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thameur-BOURBITA avatar image
0 Votes"
Thameur-BOURBITA answered CandyLuo-MSFT commented

HI,

There is a GPO setting to specify DNS resolver:


42345-image.png




please don't forget to mark this reply as answer if it help you to fix your issue


image.png (100.6 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


This group policy is only supported on XP.

0 Votes 0 ·
CandyLuo-MSFT avatar image
0 Votes"
CandyLuo-MSFT answered CandyLuo-MSFT edited

Hi ,

Based on my understanding, you want to modify DNS server via GPO only for those static IP computers. You don't want to modify DNS server for DHCP-assigned computers. Is that right? Please feel free to let me know if my understanding is wrong.

Group policies can assigned to the Active Directory organizational unit (OU) in which the computer or user are placed. So if my understanding is right, you can divide those static IP computers into a separate OU in advance and push the GPO settings.

If your static IP computers and DHCP-assigned computers are in the same OU, then you could split static IP computers into a different security group. Add the specified security group and only give this security group read and apply group policy permission. Then GPO settings will only apply to this specified security group.

42353-image.png

For how to set DNS servers via GPO, you can refer to the following article:

Set DNS servers via GPO Server 2012 R2

Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.


If the Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




image.png (21.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

FabrizioRamos-5486 avatar image
0 Votes"
FabrizioRamos-5486 answered

Hi,

there is no way to do it via command or script to all user computers excluding dhcp computers?


thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CandyLuo-MSFT avatar image
0 Votes"
CandyLuo-MSFT answered

Hi ,

there is no way to do it via command or script to all user computers excluding dhcp computers?

There is no simple command can achieve your goal. Since I am not an expert in scripting, I am not sure whether you can do it via script. You might need to write a complex script.


If the Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Evgenij-Smirnov avatar image
0 Votes"
Evgenij-Smirnov answered emilemilmammadli-6480 commented

You sure can. Run on each computer (locally or remotely)

 Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE | Where-Object {!$_.DHCPEnabled} | ForEach-Object { $_.SetDNSServerSearchOrder('8.8.8.8','8.8.8.4')}

or something along these lines.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Nice script.

0 Votes 0 ·

Hello Evgenij,

It's a great script. But it has one problem:

Cannot find an overload for "SetDNSServerSearchOrder" and the argument count: "2".

When I type only 8.8.8.8 it changes dns ip. How can I solve this problem?

0 Votes 0 ·