I have a COM object with a method that I would like to create and call from Powershell.
I know from the source code I know that the method signature is:
private DataSet MethodName(string connectionString, int userID, string location, int specID)
When I create the object in Powershell:
$obj = New-Object -ComObject My.ComObjectClass
$obj | Get-Member
The signature looks like:
MethodName Method _Recordset_Deprecated MethodName (SAFEARRAY(Variant))
So I create an array and pass it to the method:
$MyArgs = "data source=Server;Initial catalog=kickassDB",1234,"flavortown",56
$obj.MethodName([ref]$MyArgs)
But this doesn't work. I get an error:
Exception calling "MethodName" with "1" argument(s): "Type mismatch"
I think my problem is that my array is full of regular string and integer values and I need to create VARIANT's, but I don't know how to go about doing that in Powershell.
Any ideas?