How do I see all the methods/members of a COM Object?
I'm trying to get QuickTest.Applicat开发者_JS百科ion and QuickTest.RunResultsOptions COM objects, but when I access them this way, I don't get all the members that are listed in the official Help files.
PS> $app = New-Object -ComObject QuickTest.Application -Strict
PS> $app | Get-Member
For example, I know that Launch()
exists and can use it from a vbscript.
Dim app
Set app = CreateObject("QuickTest.Application")
app.Launch
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
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.
精彩评论