I have a question about how Windows PowerShell works when dealing with Com Interop.
I have a 3rd party application (let's call it ThirdPartyApp) that exposes an API that I can call into.
I can early-bind it in e.g. Excel or Visual Studio and talk to it 'directly'. I can late-bind it in VBScript and still talk to it 'directly'.
By 'directly' I mean the way I can call properties and methods exposed by the API using syntax like ThirdPartyApp.Name
So in VBScript I can do:
Dim api : Set api = CreateObject("ThirdPartyApp.API")
WScript.Echo api.Name
In PowerShell, when I do:
$api = New-Object -ComObject ThirdPartyApp.API
I have to use this syntax to get the Name:
[System.__ComObject].InvokeMember('Name',[System.Reflection.BindingFlags]::GetProperty,$null,$api,$null)
Now, I understand that that has something to do with how ThirdPartyApp was built.
I know this isn't a coding problem, and I hope I don't get downvoted immediately, but my question is: why can't I talk to this assembly the VBScript way when using Powershell? How does New-Object -ComObject in Powershell differ from CreateObject(identifier) in VBScript?