Assign the DNS Domain for a Network Adapter

Sets the DNS domain for a TCP/IP-bound network adapter.

VBScript Code


On Error Resume Next

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
    Wscript.Echo objNetCard.SetDNSDomain("fabrikam.com")
Next