Powershell: Pass parameter by name toa com object function

compowershell

How can I pass parameters to a com-object function by name rather than by position?

Specifically, I've a com-object function (Word document com-object SaveAs2) and for example I want to pass values to the 2 first parameters and to the last parameter (CompatibilityMode).

Best Answer

See this answer on Stackoverflow (short answer - you cannot directly):

https://stackoverflow.com/questions/5544844/how-to-call-a-complex-com-method-from-powershell