07-24-2023, 03:22 AM
I'm getting unexpected results from the below JScript code. The *Index* property is returned even though I've only requested *MACAddress*.
What's going on here?
**JScript:**
<!-- language: lang-js -->
var wmi, col, itr, obj;
wmi = GetObject('winmgmts:');
col = wmi.ExecQuery('SELECT MACAddress FROM Win32_NetworkAdapterConfiguration');
itr = new Enumerator(col);
for (; !itr.atEnd(); itr.moveNext()) {
obj = itr.item();
itr = new Enumerator(obj.Properties_)
for (; !itr.atEnd(); itr.moveNext()) {
obj = itr.item();
WSH.echo(obj.name)
}
}
**Output:**
Microsoft ® Windows Script Host Version 5.8
Copyright © Microsoft Corporation. All rights reserved.
Index
MACAddress
What's going on here?
**JScript:**
<!-- language: lang-js -->
var wmi, col, itr, obj;
wmi = GetObject('winmgmts:');
col = wmi.ExecQuery('SELECT MACAddress FROM Win32_NetworkAdapterConfiguration');
itr = new Enumerator(col);
for (; !itr.atEnd(); itr.moveNext()) {
obj = itr.item();
itr = new Enumerator(obj.Properties_)
for (; !itr.atEnd(); itr.moveNext()) {
obj = itr.item();
WSH.echo(obj.name)
}
}
**Output:**
Microsoft ® Windows Script Host Version 5.8
Copyright © Microsoft Corporation. All rights reserved.
Index
MACAddress