How to change the DNSSuffixSearchOrder with WMI

I have this script that was generated by wmi code creator:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
' Obtain the definition of the class.
Set objShare = objWMIService.Get("Win32_NetworkAdapterConfiguration")

' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("SetDNSSuffixSearchOrder"). _
' Add the input parameters.
objInParam.Properties_.Item("DNSDomainSuffixSearchOrder") =  ",,"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("Win32_NetworkAdapterConfiguration", "SetDNSSuffixSearchOrder", objInParam)

' List OutParams
Wscript.Echo "Out Parameters: "
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue

The script is supposed to change the values of DNSSuffixSearchOrder to those assigned to it..  But what this script does it wipes the list and selects the 2 check boxes above... Append primary... etc.  My question is, can someone modify this script to achieve my goal of being able to change the suffixes list to what I want on any PC hostname passed on to "strComputer ="?
Who is Participating?
Just out of curiosity first, is there some reason you want to script this instead of using group policy?
And this could also be done in a very simple batch file with the following commands....

reg add hklm\system\currentcontrolset\services\tcpip\parameters /v UseDomainNameDevolution /t REG_DWORD /d 1 /f
reg add hklm\system\currentcontrolset\services\tcpip\parameters /v SearchList /d ",," /f

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.