I have Powershell Script that converts XLS files into CSV file(s). it is working fine if I run this script manually but it is not working with SQL Server Agent Job. SQL Server Agent job is not throwing any error but also script is not doing anything as it is not converting XLS file into CSV.
Code of Powershell Script (Convert2CSV.ps1)
$Dir="C:\Source\TEST\Deployment\ReportOutput"
$Files =Get-Childitem $Dir -filter "*.xls"
foreach ($file in $Files)
{
$excelFile = "$Dir\"+$File
$Excel = New-Object -ComObject Excel.Application
$wb = $Excel.Workbooks.Open($excelFile)
foreach ($ws in $wb.Worksheets)
{
$ws.SaveAs($excelFile.Replace(".xls","") + ".csv", 6)
}
$Excel.Quit()
}
Below is the Powershell ExecutionPolicy on the machine. Sql Server and Powershell Script is on the same machine

