tags:

views:

58

answers:

2

i'm trying to get QuickTest.Application and QuickTest.RunResultsOptions com objects. But when i access them this way:

$qtp_app = New-Object -comobject  QuickTest.Application -strict
$qtpapp = $qtp_app | Get-Member
$qtp_RunOpt = New-Object -comobject  QuickTest.RunResultsOptions -strict
$qtprunopt = $qtp_RunOpt | Get-Member

i don't get access to all theirs members. help of quick test professional says that there is more members and i really need them. is there another way to access com objects in PowerShell?

+1  A: 

Just because Get-Member doesn't show them doesn't mean they are not there when it comes to COM objects. You will have to find some documentation to see what the member name is and what parameters it takes. This isn't a problem with .NET objects because it always has metadata availabe to describe types and type member signatures. PowerShell doesn't always have this info for COM objects.

Keith Hill
+1  A: 

In addition, PowerShell won't cast COM objects to their interfaces, which makes a bunch of methods invisible on some of the COM APIs I use. I actually have a COMObjects.Types.ps1xml file which I import in my profile:

Update-TypeData   -PrependPath "(Split-Path $Profile)\COMObject.Types.ps1xml"

The actual types.ps1xml file is on PoshCode, and it adds GetProperty/SetProperty/InvokeMethod members to COM objects for exactly this reason: accessing members that aren't visible to Powershell

Jaykul
Thanks a lot. I'm going to try it.
Varyanica
Can you give me example of usage of method 'InvokeMethod' with params?
Varyanica
i guess i found the way by myself
Varyanica
:) Sorry to leave you hanging, was on vacation ;)
Jaykul