I am performing a job from SQL server agent with a powershell command.
It was running fine a couple of days back.. there is no change in the script.
The script is also working fine if i run it via powershell.exe
Now when i run the same job its not working.... Below is the script which does a simple job of refreshing data via a macro an excel n save it as another workbook.
i get this error
A job step received an error at line 2 in a PowerShell script. The corresponding line is '$Excel = New-Object -ComObject Excel.Application'. Correct the script and reschedule the job
Script
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $true
$Excel.DisplayAlerts = $false
############## Working with Workbooks #############
$Excel.Workbooks.Open("C:\Users\dashboard\Dropbox\SMX Data\India\Data Flat Files\IntCreditors.xlsm")
$Excel.run("AutoUpdate")
$Excel.Workbooks.item("IntCreditors.xlsm").SaveAs("C:\Users\dashboard\Dropbox\SMX Data\India\Data Flat Files\IntCreditors.xlsm")
$Excel.Workbooks.Close()
$Excel.Quit()
Get-Process excel | Stop-Process -Force
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Excel)
Please help