Error in Powershell Trying to Convert Excel Spreadsheet .xlsx to .csv
Hello,
I am tasked with creating a Powershell script that will run via a SQL Server Agent Job (SQL Server 2014). The script will convert all Excel spreadsheets in a folder from from .xlsx to .csv. The script is erroring out.
Below is both the raw script as well as the run output with the error. If someone could point me in the right direction I would greatly appreciate it.
Thanks in advance.
Robert
Error:
ForEach-Object : Unable to find type [Microsoft.Office.Interop.Excel.XlFileFormat]. Make sure that the assembly that
contains this type is loaded.
At line:11 char:15
+ $ExcelFiles | ForEach-Object {
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Offic...el.XlFileFormat:TypeName) [ForEach-Object], Runtime
Exception
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand