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?
Excel.ApplicationCOM object is only available when Excel is installed. And I'm not sure if the Mac version of MS Office even provides COM objects. You may want to consider using theImportExcelPowerShell module instead.