The PowerShell script you provided is secure.
The -Scope Process
parameter ensures that this change affects only the current PowerShell process and does not impact other processes on the system or future PowerShell sessions.
Additionally, this is a very simple script that will not affect the long-term security of the computer.
perhaps script file within a SQL Server Agent job?)
A SQL Server Agent job would need to use SSIS to create an ETL project that imports .xlsx files directly into the database, eliminating the conversion step.
Furthermore, the issue you mentioned with 'MICROSOFT.ACE.OLEDB.XXXXX' not being registered can be easily resolved by installing an 80MB file named accessdatabaseengine_X64.exe.
Best regards,
Mikey Qiao
If the answer is the right solution, please click "Accept Answer" and kindly upvote it.