#161757 - 2006-05-08 06:26 PM
Re: Specific WMI Targets
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Funny you asked that. Was searching the net on this and here is another guy asking the same question ...
http://www.developersdex.com/asp/message.asp?p=1825&r=4313892
You would think that the collection returned from the wmi query would conform to the standards (reading MSDN it should) - the collection should have an Item property and a Count property - and indeed they do. But for some reason, they dont work (at least not in Kixtart) ...
Ideally you should be able to do this:
?"Username=" + $colItems.Item(0).UserName
But that no work - you should be able to do this:
?"Count = " $colItems.Count
that no work. The properties do indeed exist (because if you access some made-up proerty name, you get an unknown name error). The errors being returned from Item and Count are just generic "Unspecified errors".
I tried accessing the Count property from within for FOR/EACH loop (thinking that maybe the enumeration has to start, before these properties are valid) ... that no work either.
So idk - reading that article, even if .Item worked - the Item property takes an argument that identifies which element your looking to pull (by name) - kind of a catch 22 thing.
Bottom line (afaik) ...
1) The FOR/EACH is the best (only) way
2) The WMI designers are idiots (sorry for saying that, but they are).
-Shawn
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 581 anonymous users online.
|
|
|