# Question about COM Objects

**URL:** <https://forums.powershell.org/t/question-about-com-objects/33>\
**Category:** PowerShell Help\
**Created:** [May 7, 2013, 8:22am UTC](https://forums.powershell.org/t/question-about-com-objects/33 "2013-05-07T08:22:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![derek-engel](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@derek-engel](https://forums.powershell.org/u/derek-engel)\
**Post date:** [May 7, 2013, 8:22am UTC](https://forums.powershell.org/t/question-about-com-objects/33/1 "2013-05-07T08:22:18Z")

</div>

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}

---

<div class="post-metadata">

**Author:** ![jonhtyler](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jonhtyler/32/955_2.png) [@jonhtyler](https://forums.powershell.org/u/jonhtyler)\
**Post date:** [May 7, 2013, 8:52am UTC](https://forums.powershell.org/t/question-about-com-objects/33/2 "2013-05-07T08:52:00Z")

</div>

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.

$voice.status

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.

$voice.status.CurrentStreamNumber

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.

---

<div class="post-metadata">

**Author:** ![derek-engel](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@derek-engel](https://forums.powershell.org/u/derek-engel)\
**Post date:** [May 7, 2013, 9:00am UTC](https://forums.powershell.org/t/question-about-com-objects/33/3 "2013-05-07T09:00:43Z")

</div>

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

&nbsp;

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
- 

```auto

```

- CategoryInfo : InvalidOperation: (System.\_\_ComObject:\_\_ComObject) , RuntimeException
- FullyQualifiedErrorId : BadEnumeration

&nbsp;

You can see I’m running:

```
(New-Object -ComObject Vendor).InstalledAgents
```

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![jonhtyler](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jonhtyler/32/955_2.png) [@jonhtyler](https://forums.powershell.org/u/jonhtyler)\
**Post date:** [May 7, 2013, 10:52am UTC](https://forums.powershell.org/t/question-about-com-objects/33/4 "2013-05-07T10:52:00Z")

</div>

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

$vendor = new-object -comobject Vendor  
$vendor.InstalledAgents

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.

---

<div class="post-metadata">

**Author:** ![derek-engel](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@derek-engel](https://forums.powershell.org/u/derek-engel)\
**Post date:** [May 7, 2013, 11:47pm UTC](https://forums.powershell.org/t/question-about-com-objects/33/5 "2013-05-07T23:47:43Z")

</div>

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
- 

```auto

```

- CategoryInfo : InvalidOperation: (System.\_\_ComObject:\_\_ComObject) , RuntimeException
- FullyQualifiedErrorId : BadEnumeration

---

<div class="post-metadata">

**Author:** ![jonhtyler](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jonhtyler/32/955_2.png) [@jonhtyler](https://forums.powershell.org/u/jonhtyler)\
**Post date:** [May 7, 2013, 11:54pm UTC](https://forums.powershell.org/t/question-about-com-objects/33/6 "2013-05-07T23:54:24Z")

</div>

Let’s try something a little different, then…

Assign the .InstalledAgents property to a variable

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

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.

---

<div class="post-metadata">

**Author:** ![derek-engel](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@derek-engel](https://forums.powershell.org/u/derek-engel)\
**Post date:** [May 8, 2013, 1:01am UTC](https://forums.powershell.org/t/question-about-com-objects/33/7 "2013-05-08T01:01:04Z")

</div>

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)
- 

```auto

```

- CategoryInfo : OperationStopped: (🙂 , 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.

---

<div class="post-metadata">

**Author:** ![jonhtyler](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jonhtyler/32/955_2.png) [@jonhtyler](https://forums.powershell.org/u/jonhtyler)\
**Post date:** [May 8, 2013, 1:09am UTC](https://forums.powershell.org/t/question-about-com-objects/33/8 "2013-05-08T01:09:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![derek-engel](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@derek-engel](https://forums.powershell.org/u/derek-engel)\
**Post date:** [May 8, 2013, 5:10am UTC](https://forums.powershell.org/t/question-about-com-objects/33/9 "2013-05-08T05:10:34Z")

</div>

When I run:

```
$a = New-Object -ComObject vendor
$a
```

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?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/question-about-com-objects/33/10 "2024-05-16T20:57:48Z")

</div>


