Configure DNS Suffix for this Connection Script

I happened to need a script to set the active nics DNS suffix on all of my machines so i wrote this little script to do just that. I first looked to see if anyone else had already wrote something and found a lot of people looking for this same thing but no one really finding a solution. Save the below to CFG.DNSDomain.vbs and set the StrDNSDomain variable and you are ready to go…

Option Explicit

Dim objWMIService, objItem, colItems, strComputer, StrDNSDomain

strComputer ="."
StrDNSDomain ="YOURDOMAIN.COM"

Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=True")

On error Resume Next

For Each objItem In colItems
‘WScript.Echo objItem.DNSDomain
objItem.SetDNSDomain(StrDNSDomain)
Next

email

Written by , Posted .