I have a powershell script which deletes old backups from NAS storage. I have already tested it using Windows Powershell and it works but I couldn't perform the same thing in SQL Server. I have created a cmdExec type job and then wrote the script below (script is on desktop):
"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe"
"C:\Users\domainAccount\Desktop\"
".\deleteold.ps1 -FolderPath \\192.168.x.x\Backups -FileAge 2 -ListOnly -LogFile \\192.168.x.x\Backups\log.log"
But I do not get any result as when I run the job it just keeps running infinitely until I stop that job.
powershell -ExecutionPolicy RemoteSigned -File "C:\Users\domainAccount\Desktop\\deleteold.ps1" -FolderPath "\\192.168.x.x\Backups" -FileAge 2 -ListOnly -LogFile "\\192.168.x.x\Backups\log.log"