Question about COM Objects

I’m working with a third party .NET COM object. Â I realize that none of you have the documentation for this COM object. Â I’m hoping with my description you can point me in the right direction to find what I need.

First things first. Â In PowerShell I create a new object

New-Object -ComObject vendor

If I were to execute that, I would get a bunch of stuff returned. Â For example:

ServerRevision        : 8400

In turn, I could now run the following PowerShell:

(New-Object -ComObject vendor).serverrevision

One of the items that I see returned is a field called: Â installedagents.

This installedagents does not have an actual value. Â It just says: Â System.__ComObject

My questions is.  What the heck do I do with that System.__ComObject?

If it helps, when I pipe the COM object to get-member, the entry for installedagents says this:

InstalledAgents        Property        IAeXInstalledAgents InstalledAgents () {get}

Hi Lery,

Since I don’t have your COM object, I used the most recent and closest one I could find; the Voice COM object in Windows 7.

$voice = new-object -ComObject sapi.spvoice

When I call the $voice variable, it shows me some properties, that as you show, have System.__ComObject. Â When I call into one of those properties, it just enumerates its value.


PS C:\Windows\system32> $voice.status
CurrentStreamNumber : 1
LastStreamNumberQueued : 1
LastHResult : 0
RunningState : 1
InputWordPosition : 57
InputWordLength : 1
InputSentencePosition : 8
InputSentenceLength : 51
LastBookmark :
LastBookmarkId : 0
PhonemeId : 7
VisemeId : 0

and finally, if I continue to dig into the property, I can get a specific value.


returns 1.

So you should be able to call into the properties just like you do native objects. Â Hope this helps. Â Someone may have much more experience with this than I do, but this is what I have done so far.

Thanks Jonathan. Â I thought the same. Â So I ran it before posting. Â Here is the error returned:


An error occurred while enumerating through a collection: The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)).
At line:2 char:1

  • (New-Object -ComObject Vendor).InstalledAgents
  • CategoryInfo : InvalidOperation: (System.__ComObject:__ComObject) [], RuntimeException
  • FullyQualifiedErrorId : BadEnumeration


You can see I’m running:

(New-Object -ComObject Vendor).InstalledAgents



Dumb question, but have you attempted to generate an object first and then try to access the property?

$vendor = new-object -comobject Vendor

The only other thing I can think of is that you might have to use a .GetEnumerator() to start enumerating the items in the collection. Â Beyond that, maybe someone else here has some input they can share. Â I don’t deal much with COM objects, so I am afraid we are quickly running to the limits of my knowledge…especially without further knowledge of the API behind your object.

Yes sir, tried that. Â Error I get is:

An error occurred while enumerating through a collection: The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)).
At line:9 char:1

  • $vendor.InstalledAgents
  • CategoryInfo : InvalidOperation: (System.__ComObject:__ComObject) [], RuntimeException
  • FullyQualifiedErrorId : BadEnumeration

Let’s try something a little different, then…

Assign the .InstalledAgents property to a variable

$agents = $vendor.InstalledAgents
foreach ($agent in $agents)

This keeps powershell from doing an automatic enumeration, which may be causing the problem. Â This way, you are getting a static copy of the InstalledAgents property and then enumerating over that collection. Â Shot in the dark, but it might work. Â Let me know.

Was worth the shot, but same error:

The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
At line:4 char:10

  • foreach ($agent in $agents)
  • CategoryInfo : OperationStopped: (:slight_smile: [], COMException
  • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

I think it has something to do with the property.  For example, I can look at another property with no issues.  Example is ServerRevision.  When I ask for that property it returns:  8400

But when I’m looking at all the properties available, InstalledAgents has System.__ComObject listed instead of actual values.  It should have maybe 5 string values in that property.  Not System.__ComObject.  I’m not sure why or what System.__ComObject means in a property.

Well, that is new information to work with, so I count that as some progress.

My thoughts now (and again, not being familiar with your COM object, so this is a serious WAG, here) is that there may be an assembly that needs to be loaded so that it knows how to interpret that object from InstalledAgents. Â Unfortunately, there is no magic ball I can look into to tell you what that might be.

Perhaps the vendor has some documentation or you might find someone on the Internet who works for them who might be able to give you a clue.  The vendor might even have  a support forum where you can post a question.  That would probably be a long-shot, even if they did have a forum to post a question to.

I’ll keep thinking about it to see if something comes to mind, but I got nothin’ right this minute. Â Sorry I couldn’t help more.

When I run:

$a = New-Object -ComObject vendor

In addition to figuring out why it does not work when I run $a.installedagents, I would like to understand what it means when I see System.__ComObject listed instead of an actual value?