Learn how to a build a cloud-first strategyRegister Now


How to change the DNSSuffixSearchOrder with WMI

Posted on 2006-04-27
Medium Priority
Last Modified: 2008-01-09
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") =  "sample1.one.com, sample2.two.com, sample3.three.com"

' 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 ="?
Question by:hplaud5035
  • 3
LVL 24

Expert Comment

ID: 16557295
Just out of curiosity first, is there some reason you want to script this instead of using group policy?
LVL 24

Expert Comment

ID: 16557498
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 "domain1.com,domain2.com,domain3.com....." /f

LVL 24

Accepted Solution

Kenneniah earned 2000 total points
ID: 16557609

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question