How to create a job that uses Powershell script? 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.
You need to pass the powershell file in as an argument 

powershell.exe -file C:\Users\domainAccount\Desktop\deleteold.ps1 -FolderPath \\192.168.x.x\Backups -FileAge 2 -ListOnly -LogFile \\192.168.x.x\Backups\log.log


Or if the step type doesn’t have to be CmdExe you can change the type to PowerShell