We help IT Professionals succeed at work.
Get Started

Scheduling a powershell script as a sql agent job

709 Views
Last Modified: 2012-05-12
I have a script that when I run straight from powershell or as a windows scheduled task works
fine.

The script does a bcp to my logs into a csv file zips it then deletes the zip.  When I run the script as a scheduled job from sql the job says it has completed but the zip is not deleted. When I check the history I see this message.

Executed as user: host\g. 1  Starting copy...    0 rows copied.  Network packet size (bytes): 4096  Clock Time (ms.): total        1  7-Zip  4.60 beta  Copyright (c) 1999-2008 Igor Pavlov  2008-08-19  Scanning    Creating archive O:\LogsTest\log_.zip    Compressing  exceptionlog_1_.csv    Everything is Oklog_1_ was not found in O:\LogsTest\.  Process Exit Code 0.  The step succeeded.

Any idea why this is happening? I know I have some other zip questions out there but this is unrelated.

I am trying to run this from server 2003 / sql server 2005.

I have also tested this on server 2008 / sql 2008 and the script worked perfect.

The way I am calling the script from server 2003 / sql 2005 is like so.

Type Operating system cmd, run as SQL agent service
powershell.exe c:\logtest.ps1

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE