We have a Powershell script that automates Excel. It's been working fine in Powershell 2.0 for some time. Recently our servers automatically updated the WMF and Powershell to 3.0, and lines like the following all started failing: $workbook.Application.Run("someFunc", [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing, [Type]::Missing) with: Invoke-Command : Exception calling "Run" with "31" argument(s): "Invalid number of arguments." Note that this appears to be directly related to WMF 3 rather than the change from CLR 2.0 to 4.0:On my WMF 2.0 test box I changed my powershell.exe.config to the following: <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0.30319"/> </startup> </configuration> My theory is that now my Powershell 2.0 process can only load the 4.0 CLR (I confirmed that it indeed does load the 4.0 CLR), and my original script with 31 arguments should now fail in that shell. In fact it works fine.
Have you seen this problem before in this product?
Please wait...