I have a simple PowerShell script that has 1 line. It logs into a database,and runs a sql script of queries, that deletes old data.
sqlcmd -U myUser -P myPassword -S localHost -i .\deleteOldData.sql
When I run the script manually in PowerShell window, it works perfectly fine. It will login to the database and clear the old data. But when I created a basic task in the task scheduler and run it from there, it says it completes successfully, but it isn't look like its doing anything. It does not delete any of the old data.
My basic task is setup like
Action: Start a program
Program/script: PowerShell
Add Arguments: C:\Users\Administrator\Desktop\script.ps1