Domanda

I'm interested in communicating with an OLE Automation (IDispatch) server from Windows Powershell. Can anyone point me to some simple sample code that illustrates doing this? I know I can use New-Object -com My.App.Interface to create the object, but then talking to it is a different matter. In this case its an OLE Automation (IDispatch) interface, so I'm not just calling methods right on the returned object, I'm calling the Invoke method of IDispatch.

So, anyway, just wondering if anyone can point me to some samples for doing this that I can use as a starting point.

È stato utile?

Soluzione

$a=new-object -com ....
[System.__ComObject].invokemember(<Method>,[System.Reflection.BindingFlags]::invokeMethod,$null,$a,<args>)
[System.__ComObject].invokemember(<Property>,[System.Reflection.BindingFlags]::GetProperty,$null,$a,<args>)

Altri suggerimenti

I would recommend using Get-Member to reflect over the object and discover what methods are available to you. Do you have any additional information about which specific COM object we're talking about here? Is it something built into Windows, or a 3rd party COM object?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top