Lydia626
asked on
Scheduling a powershell script as a sql agent job
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
On the Server 2003 system, what version of PowerShell is installed?
ASKER
This ended up being a permissions issue.
ASKER