I had a COM object created in PowerShell: $CivicFactory = new-object -comObject LocationDisp.CivicAddressReportFactory
I need to implement the event handler for "NewCivicAddressReport". I tried this:
Register-ObjectEvent $CivicFactory -EventName "NewCivicAddressReport" -Action ({ echo "haha" })
But it gave me "Register-ObjectEvent : Cannot register for event. An event with name 'NewCivicAddressReport' does not exist."
Then I tried $CivicFactory.add_NewCivicAddressRerport( {"haha"} )
It did not work either: Method invocation failed because [System.__ComObject#{bf773b93-c64f-4bee-beb2-67c0b8df66e0}] doesn't contain a method named 'add_NewCivicAddressRerport'.
Can anyone tell me how to implement this event handler in PowerShell? Thanks in advance. In VBScript it is as simple as
Function CivicFactory_NewCivicAddressReport(report)
Blablabla...
End Function
But in PowerShell I couldn't get it working.