'Open multiple HTML files and save as XLSX using PowerShell

How do I open multiple HTML files (tabular format) and save them as Excel XLSX format in Windows PowerShell ISE? Directly renaming file extension removes all the formatting. It was working with a single file. I need help with the looping part?

$FolderPath = 'C:\Users\abcd\Desktop\New folder'


$FilePaths = get-childitem $FolderPath -recurse | where {$_.extension -eq ".html"} 

foreach($FilePath in $FilePaths)
{
$Workbook = $Excel.Workbooks.Open($FilePath)
$Excel.Visible = $true
$Excel.DisplayAlerts = $False

$OutFile     = 'C:\Users\abcd\Desktop\New folder\...xlsx' #Need same file names
$xlSLSXType  = 51
$workBook.SaveAs("$OutFile",$xlSLSXType)

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source