I am trying to load an Excel file using PowerShell Core for Mac but I am encountering an issue with New-Object. It's failing on the very first line
$Excel = New-Object -ComObject Excel.Application
This is the error message I receive:
New-Object : A parameter cannot be found that matches parameter name
'ComObject'.
At line:1 char:21
+ $Excel = New-Object -ComObject Excel.Application
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Has anyone encountered this issue and does anyone know how to fix it?
The error message you're receiving says the
-ComObjectparameter is invalid. Judging from this issue posted on the powershell github I'd say-ComObjectis invalid because it is not supported on the Mac platform.