How to use PowerShell to access methods and properties of a Third-Party OLE DLL?

半世苍凉 提交于 2019-12-22 10:54:35

问题


I am trying to write a PowerShell script which could access methods and properties of a third-party OLE DLL.

The software vendor provided a working example in vbscript to achieve the same result. Below is an excerpt of the codes:

Set objOLE = CreateObject("NETIQOLE.APPMANAGER")
objOLE.Logon strInstance, strRepository, strUserID, strPwd
...

However, when I tried to code in PowerShell as below:

$objOLE = New-Object -ComObject "NETIQOLE.APPMANAGER"
$objOLE | Get-Member

I got output below and didn't see any relevant method or property.

   TypeName: System.__ComObject

Name                      MemberType Definition                                                     
----                      ---------- ----------                                                     
CreateObjRef              Method     System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Equals                    Method     bool Equals(System.Object obj)                                 
GetHashCode               Method     int GetHashCode()                                              
GetLifetimeService        Method     System.Object GetLifetimeService()                             
GetType                   Method     type GetType()                                                 
InitializeLifetimeService Method     System.Object InitializeLifetimeService()                      
ToString                  Method     string ToString() 

Is there anything I can do to access to this OLE Dll's methods and proerties? Any advice or sample codes are welcome. Thank you in advance.


回答1:


Thank you both for your kind responses. The link given by @Ekkehard.Horner worked. It really save my day.

The working codes are now:

$credential = "...", "...", "...", "..."
[System.__ComObject].InvokeMember("Logon", [System.Reflection.BindingFlags]::InvokeMethod, $null, $netiqObj, $credential)


来源:https://stackoverflow.com/questions/22623773/how-to-use-powershell-to-access-methods-and-properties-of-a-third-party-ole-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!