The following snippet will add connection-specific dns suffix to a specific local are network connection. Copy the snippet and save it to a file say setdnssuffix.wsf and run as wscript setdnssuffix.wsf /DNSDomainSuffix:"mysuffix.com" on command prompt. here "mysuffix.com" is dns suffix need to be added.
You can download the script at SetDnsSuffix
Public DNSDomainSuffix
Set colNamedArguments =WScript•Arguments.Named
DNSDomain = colNamedArguments.Item ("DNSDomainSuffix")
NetConnName = colNamedArguments.Item("netConnName")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapter")
For Each objItem in colItems
If Not IsNull(objItem.NetConnectionID) Then
if objItem.NetConnectionID = NetConnName Then
strMacAddress = objItem.MacAddress
end if
End If
Next
call ExecuteDnsSuffix (WMIEchoStr)
Function ExecuteDnsSuffix(WMIEchoStr)
strComputer = "•"
Set objWMIService = GetObject("winmgmts:"
& "{impersonationLevel=impersonate}!¯\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery –
("Select * From Win32–NetworkAdapterConfiguration Where IPEnabled =True")
For Each objNetCard in colNetCards
ExecuteDnsSuffix=objNetCard•SetDNSDomain(DNSDomain)
Next
WMIEchoStr=DNSDomain
End Function
<\script>
<\job>
This is just what I need
ReplyDeleteDo you have a way to tick the following boxes as well?
- Register this connection's addresses in DNS
- Use this connection's DNS suffix in DNS registration
netsh interface ipv4 set dnsservers name="Local Area Connection" source=dhcp register=both
ReplyDelete