I have written an inventory script for our network that works fine on 90% of the computers but on few of them I get this error :
select IPAddress,IPSubnet,MacAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE
-2147319779Library not registered.

and on a few others I get this error :
select IPAddress,IPSubnet,MacAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE
6The handle is invalid.

The code in question is :
$IpSet = GetObject('winmgmts:').ExecQuery('select IPAddress,IPSubnet,MacAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE')

$x = 0
If @error <> 0
? @error + " / " @serror
else
For Each $IPConfig In $IPSet

? "<MAC"+ $x + ">" + $IPConfig.MacAddress(0) + "</MAC" + $x + "> "

? "<IP" + $x + ">" + $IPConfig.IPAddress(0) + "</IP" + $x + "> "

? "<Subnet"+ $x + ">" + $IPConfig.IPSubnet(0)+ "</Subnet" + $x + "> "


$x = ($x + 1)
Next
? "<NumberOfIPs>$x</NumberOfIPs>";
EndIf

Does anyone have any suggestions?