How to change the DNSSuffixSearchOrder with WMI
Posted on 2006-04-27
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 ="?