We have a number of Excel files that are stored in .xlsx or .xlsm format. Unfortunately the last letter of the file extension got dropped in another IT system so that they all have the file extension .xls. But we also have Excel files stored in .xls format.
I would need to write a PowerShell script to detect the actual Excel file format and then rename the files so that they file extension fits to the content. We have thousands of these files so it is not an option to it manually.
I found information on how to differentiate between .xls and the newer XML formats like .xlsx and .xlsm (by inspecting the first characters in the file). But I have not yet been able to find any information on how to determine if it is an .xlsx or .xlsm.