bibi92
asked on
execute powershell with parameters in sql agent job
Hello,
I can execute the following script in cmdexec window. But when I add it on a step in SQL AGENT Job, the job executed successfully but do nothing :
powershell -nologo -command "& {&'c:\script\backup_disk.p s1' -I SRVTEST -T F -R 24 -D \\nas$\srvtest -L C:\script\logs}"
Thanks
Regards
I can execute the following script in cmdexec window. But when I add it on a step in SQL AGENT Job, the job executed successfully but do nothing :
powershell -nologo -command "& {&'c:\script\backup_disk.p
Thanks
Regards
In the step properties(in edit window) make sure that the type of command is Powershell instead of Transact-SQL.
ASKER
It's an cmdexec step and not transact-sql.
There is also Powershell command.
ASKER
ok I know but I have to replace powershell command by cmdexec because there are only two threads powershell for SQL AGENT.
Have you actually tried seeing what happens when your script is run by sql agent ?
Try adding the Executionpolicy to your powershell command, it may be an execution restriction issue.
powershell -Executionpolicy Bypass -nologo -command "& {&'c:\script\backup_disk.p s1' -I SRVTEST -T F -R 24 -D \\nas$\srvtest -L C:\script\logs}"
Try adding the Executionpolicy to your powershell command, it may be an execution restriction issue.
powershell -Executionpolicy Bypass -nologo -command "& {&'c:\script\backup_disk.p
ASKER
Have you actually tried seeing what happens when your script is run by sql agent ?
Yes, I have add output log in the step but the file is empty
I have tested , but same result :
powershell -Executionpolicy Bypass -nologo -command "& {&'c:\script\backup_disk.p s1' -I SRVTEST -T F -R 24 -D \\nas$\srvtest -L C:\script\logs}"
Thanks
Yes, I have add output log in the step but the file is empty
I have tested , but same result :
powershell -Executionpolicy Bypass -nologo -command "& {&'c:\script\backup_disk.p
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you maybe put a start and stop transcript into your backup_disk.ps1 script and take a look at the output.
It might be an issue with a parameter or some other input.