RE: Subject: configure DNS suffix search on win2003 WMI.
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng [MSFT])
- Date: Fri, 01 Aug 2008 11:03:50 GMT
Hi teilo,
How are you doing?
Have you got any progress on this issue or does the information in my last
reply help you some?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng [MSFT])
Organization: Microsoft
Date: Wed, 30 Jul 2008 06:57:51 GMT
Subject: RE: Subject: configure DNS suffix search on win2003 WMI.
u
Hi teilo,
From your description, you're encountering some problem when try using WMIcode to configure the DNS server suffix, correct?
As for DNS suffix setting, I've found some script sample from technet
scirpt repository:
#Configuring Network Settings
http://www.microsoft.com/technet/scriptcenter/scripts/jscript/misc/wmi/defa
lt.mspx?mfr=true-
since the sample is vbscript based, I've tested via the changed jscript
code below and it works:
=====jscript test =========
var strComputer = ".";
var arrNewDNSSuffixOrder =new Array("mycompany.com", "east.mycompany.com")
var objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + strComputer +
"\\root\\cimv2");
var Network = objWMIService.Get("Win32_NetworkAdapterConfiguration");
// nowthe new DNS suffix search order
var SetSuffixes = Network.SetDNSSuffixSearchOrder(arrNewDNSSuffixOrder);
if(SetSuffixes == 0){
WScript.Echo("Success! Replaced DNS domain suffix search order.");
}else if(SetSuffixes == 1){
WScript.Echo("Success! Replaced DNS domain suffix search order ? pls.
reboot.");
}else{
WScript.Echo("Error! Unable to replace DNS domain suffix search order
list.");
}
==========================
the above code will set the DNS suffix array for all the network adapters
on local computer.
BTW, for WMI, there is a WMI code creator which is also very helpful for
generate code of WMI configuration:
#WMI Code Creator v1.0
http://www.microsoft.com/downloads/details.aspx?FamilyID=2cc30a64-ea15-4661
8da4-55bbc145c30e&displaylang=enf
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#noti
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?dGVpbG9Abm9zcGFtLm5vc3BhbQ==?= <teilo@xxxxxxxxxxxxx>
Subject: Subject: configure DNS suffix search on win2003 WMI.
Date: Tue, 29 Jul 2008 08:52:00 -0700
running
Hi all,
I have a script to configure network settings on multihomed computer
win2003 SP1. Everything is ok except I can't configure the DNS suffixsearch
list."yellow.lab.example.com");
I have tried the following and all fail (invalid method):
nicConfig.SetDNSSuffixSearchOrder(dnsSearch);
nicConfig.EnableDNS();
nicConfig.EnableDNS("computer1", dnsDomain, dnsServers, dnsSearch);
where the following variables have been set
var dnsDomain = "green.lab.example.com";
var dnsServers = new Array("192.168.1.2", "192.168.2.2");
var dnsSearch = new Array("green.lab.example.com",
"yellow.lab.example.com");
Anyone any ideas on whats wrong or any alternative solutions?
The above is part of the following script that is run as the local
administrator - machine is not part of a domain.
<job>
<script language="JScript">
var dnsDomain = "green.lab.example.com";
var registerDNS = false;
var dnsServers = new Array("192.168.1.2", "192.168.2.2");
var dnsSearch = new Array("green.lab.example.com",
main();
function convertDynamic(nicConfig) {
try {
var ipAddress = nicConfig.IPAddress(0);
var mask = nicConfig.IPSubnet(0);
var gateway = nicConfig.DefaultIPGateway(0);
var convert = false;
if (ipAddress.indexOf("192.168.3.") == 0) {
convert = true;
}
if (convert) {
WScript.Echo("converting", ipAddress, "to static ip");
WScript.Echo(" on adapter", nicConfig.Caption);
WScript.Echo(" ", nicConfig.Name);
nicConfig.EnableStatic(new Array(ipAddress), new Array(mask));
nicConfig.SetGateways(new Array(gateway), new Array(1));
if (!control) {
nicConfig.SetIPConnectionMetric(20);
}
nicConfig.SetDNSServerSearchOrder(dnsServers);
nicConfig.SetDNSDomain(dnsDomain);
/* the following commented out lines blow up */
//nicConfig.SetDNSSuffixSearchOrder(dnsSearch);
//nicConfig.EnableDNS();
//nicConfig.EnableDNS("computer1", dnsDomain, dnsServers, dnsSearch);
nicConfig.SetDynamicDNSRegistration(registerDNS,registerDNS);
nicConfig.SetDNSSuffixSearchOrder(dnsSearch);
}
else {
WScript.Echo("Not converting dynamic address", ipAddress, "to static");
WScript.Echo(" on adapter", nicConfig.Caption);
}
}
catch (err) {
WScript.Echo("oops", err);
}
}
/**
* find all adapters with DHCP and convert its currently assigned dhcp
address to static.
*/
function main() {
var wmiService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\CIMV2");
var nicConfigs = wmiService.ExecQuery("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = True");
var enumItems = new Enumerator(nicConfigs);
for (; !enumItems.atEnd(); enumItems.moveNext()) {
var nic = enumItems.item();
if (nic.DHCPEnabled) {
convertDynamic(nic);
}
}
}
</script>
</job>
.
- Next by Date: About the orignal height&width of img
- Next by thread: About the orignal height&width of img
- Index(es):
Relevant Pages
|
Loading