0

Is there some microsoft libary that installs the COM classes needed without actually installing O365 on a server to just run a powershell program? When we try to run on a workstation with O365, no problem but if we run on a server without O365 installed we get this sort of error:

New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
+ $excel = New-Object -ComObject excel.application
    + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
2
  • Most likely the .net package you have installed. What PSVersion and .Net you running on the server? Commented Apr 7, 2021 at 16:40
  • It is true some .Net classes have COM interfaces. And COM can certainly be access from .Net code/languages. However, I'm skeptical there's anything resembling the Excel Object Model exposed directly via .Net without an underlying reliance on that object model which is only present with Excel. Commented Apr 7, 2021 at 18:02

1 Answer 1

5

As far as I know the Excel Object Model (EOM) is only installed with Excel. I don't know of a way to get the model installed otherwise. However, ImportExcel a PowerShell module from MVP Doug Fink can work with Excel workbooks without Excel installed. I use it all the time, and would argue it's easier too.

See this Scripting Guys article with techniques using ADO (COM) & ADO.Net to access Excel data.

I also double checked if Visual Studio Tools for Office (VSTO) and/or MS Office Primary Interop Assemblies could be used for this. However, these assemblies appear to act as an interface between managed code and the COM objects (EOM).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks - that's what I was afraid of - I'll look into that. Appreciate the feedback.
I wish I had better news. My personal opinion is ImportExcel is much easier and very capable. It allows you to work with the Excel data as you would any other set of PoSh objects which removes a good bit of syntax overhead that comes with the COM approach. For example you don't need to loop as much. At any rate, if you're satisfied with the answer please consider accepting. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.