Why it fails when running from SQL Server Agent ?

I'm new in Powershell. Recently I installed Powershell 2.0. Everything works 
fine when I ran interactively. But when I schedule a DTS as SQL Sever job it 
fails with the following error:

Executed as user: MHPNT\mhpsqlservice. File J:\eventviewer\GetSystemLog.ps1 
cannot be loaded because the execution of   scripts is disabled on this 
system. Please see "get-help about_signing" for mor  e details.  At line:1 
char:2  + & <<<<  'j:\eventviewer\GetSystemLog.ps1'      + CategoryInfo       
   : NotSpecified: (:) [], PSSecurityException      + FullyQualifiedErrorId : 
RuntimeExceptionDTSRun:  Loading...   DTSRun:  Executing...   DTSRun OnStart: 
 DTSStep_DTSExecuteSQLTask_4   DTSRun OnFinish:  DTSStep_DTSExecuteSQLTask_4  
 DTSRun OnStart:  DTSStep_DTSCreateProcessTask_1   DTSRun OnError:  
DTSStep_DTSCreateProcessTask_1, Error = -2147220330 (80040496)      Error 
string:  CreateProcessTask 'DTSTask_DTSCreateProcessTask_1':  Process 
returned code 1, which does not match the specified SuccessReturnCode of 0.   
   Error source:  Microsoft Data Transformation Services (DTS) Package      
Help file:  sqldts80.hlp      Help context:  4900      Error Detail Records:  
    Error:  -2147220330 (80040496); Provider Error:  0 (0)      Error string: 
 CreateProcessTask 'DTSTask_DTSCreateProcessTask_1':  Process returned code 
1, which does not match the specified SuccessReturnCode of 0.      Error 
source:  Microsoft Data Transformation Services (DTS) Package      Help file: 
 sqldts80.hlp      Help context:  4900      DTSRun OnFinish:  
DTSStep_DTSCreateProcessTask_1   DTSRun:  Package execution complete.  
Process Exit Code 1.  The step failed.

Within the DTS, one of the task was "Execute Process Task" which executes: 
powershell.exe -command "& { J:\eventviewer\GetSystemLog.ps1}"

Based on the error, I thought I need to add "set-executionpolicy 
unrestricted" to the profile, so I added it to the profile which is located 
at C:\WINDOWS\system32\windowspowershell\v1.0. But it didn't help and I still 
get the error "....File J:\eventviewer\GetSystemLog.ps1 cannot be loaded 
because the execution of   scripts is disabled on this system. Please see 
"get-help about_signing" for mor  e details." in the job history.

I also checked execution policy using get-executionPolicy and it returns 
"unrestricted".

Can someone help me: why the script fails when I run as SQL Server job ?

FYI, I'm running on Windows Server 2003 64-bit SP2 and SQL Server 2008 
Enterprise Edition (64-bit) RTM.

Thanks in advance,
Jimmy

0
Utf
5/25/2010 2:30:01 PM
windows.powershell 690 articles. 0 followers. Follow

1 Replies
2806 Views

Similar Articles

[PageSpeed] 14

I just found out why it was failing:

when the job is running, it runs in the context of the account that starts 
the SQL Server Agent Service. So I decided to remote desktop to the server 
where the job is located and run it from there with -noexit just to check the 
execution policy. When it comes to the task that runs Powershell script, it 
kicks off a command-line window with the error that I mentioned. Then, I 
checked the execution policy, it was "resctricted". So, while still in the 
command-line window, I changed  the execution policy to "RemoteSigned" and 
then exit it. After this change, I re-ran the job from Management Studio from 
my PC (instead of remote desktop to the server) and it ran successfully.

"jimmycjen" wrote:

> I'm new in Powershell. Recently I installed Powershell 2.0. Everything works 
> fine when I ran interactively. But when I schedule a DTS as SQL Sever job it 
> fails with the following error:
> 
> Executed as user: MHPNT\mhpsqlservice. File J:\eventviewer\GetSystemLog.ps1 
> cannot be loaded because the execution of   scripts is disabled on this 
> system. Please see "get-help about_signing" for mor  e details.  At line:1 
> char:2  + & <<<<  'j:\eventviewer\GetSystemLog.ps1'      + CategoryInfo       
>    : NotSpecified: (:) [], PSSecurityException      + FullyQualifiedErrorId : 
> RuntimeExceptionDTSRun:  Loading...   DTSRun:  Executing...   DTSRun OnStart: 
>  DTSStep_DTSExecuteSQLTask_4   DTSRun OnFinish:  DTSStep_DTSExecuteSQLTask_4  
>  DTSRun OnStart:  DTSStep_DTSCreateProcessTask_1   DTSRun OnError:  
> DTSStep_DTSCreateProcessTask_1, Error = -2147220330 (80040496)      Error 
> string:  CreateProcessTask 'DTSTask_DTSCreateProcessTask_1':  Process 
> returned code 1, which does not match the specified SuccessReturnCode of 0.   
>    Error source:  Microsoft Data Transformation Services (DTS) Package      
> Help file:  sqldts80.hlp      Help context:  4900      Error Detail Records:  
>     Error:  -2147220330 (80040496); Provider Error:  0 (0)      Error string: 
>  CreateProcessTask 'DTSTask_DTSCreateProcessTask_1':  Process returned code 
> 1, which does not match the specified SuccessReturnCode of 0.      Error 
> source:  Microsoft Data Transformation Services (DTS) Package      Help file: 
>  sqldts80.hlp      Help context:  4900      DTSRun OnFinish:  
> DTSStep_DTSCreateProcessTask_1   DTSRun:  Package execution complete.  
> Process Exit Code 1.  The step failed.
> 
> Within the DTS, one of the task was "Execute Process Task" which executes: 
> powershell.exe -command "& { J:\eventviewer\GetSystemLog.ps1}"
> 
> Based on the error, I thought I need to add "set-executionpolicy 
> unrestricted" to the profile, so I added it to the profile which is located 
> at C:\WINDOWS\system32\windowspowershell\v1.0. But it didn't help and I still 
> get the error "....File J:\eventviewer\GetSystemLog.ps1 cannot be loaded 
> because the execution of   scripts is disabled on this system. Please see 
> "get-help about_signing" for mor  e details." in the job history.
> 
> I also checked execution policy using get-executionPolicy and it returns 
> "unrestricted".
> 
> Can someone help me: why the script fails when I run as SQL Server job ?
> 
> FYI, I'm running on Windows Server 2003 64-bit SP2 and SQL Server 2008 
> Enterprise Edition (64-bit) RTM.
> 
> Thanks in advance,
> Jimmy
> 
0
Utf
5/25/2010 5:08:01 PM
Reply:

Similar Artilces:

Rejected by Server
When sending mail, I get an error with "rejected by server". The e-mail is still sent, but I get this error message every time. You are hiding some of the details. The reject error would show some status error number, like 550, and an error code, like 0x.....CE. Are you sending e-mails using your ISP's SMTP (outbound) mail server? Or are you connected to their network but trying to relay SMTP requests across their network to an SMTP server on someone else's network? That's a no-no since many ISP's will not let you relay SMTP traffic across their network (except,...

can servers be moved between administrative groups?
Below is an extract from the 70-284 MS training kit. I am totaly confused i have been told in this newsgroup by an MVP that you can not move a server once installed to a different administrative group and have also read elsewhere that you cannot but Microsoft below say you can in both modes. Subsequent Exchange servers are added to routing groups during the installation process,and if necessary, you can move servers between routing groups using Exchange System Manager. The only caveat is that in mixed mode, you cannot move servers between routing groups that belong to different administrative...

Outlook2003 : keeping a copy of PST on server
I can't seem find the place to make the change on the client's outlook to keep a copy of the pst file on exchange server. When I configured outlook I got the message to go into tools and select the option to keep a copy on server. I couldn't find that option and all mail was delivered to the client. When you go through owa all you will see is the new mail not delivered to the client. I'm going to hack at it and when I find something I will post my findings. But if someone already knows where to look I would appreciate that Thanks Norm found this article http://www...

Two mailboxes for one user account after mailbox moved to a new server
After moving a user's mailbox from a Exchange 2003 to a new Exchange 2003 server, Outlook has listed two mailboxes with same name in the "All Mail Folders"area. The Outlook profile only has the user mailbox and no other mailboxes added to it. The user can send and recieve email just fine. The mailboxes seem to be clones of each other. New mail show up in the mailboxes at the sametime. How can I get Outlook to only show one mailbox? Any help would be appreciated, thanks, ...

SQL in Excel data
Hi all, Is there a possibility/way to run an SQL query in an excel data sheet? I have quite some data like the sample below, now i would like to have the sum of spending for each person. Like it is possible in Access. A1 B1 Field1 Field2 Chuck 12,89 Mike 23,09 Jean 9,34 Chuck 30,00 Mike 3,80 Chuck 22,00 Mike 7,23 Jean 10,55 Jean 10,75 Jean 31,45 Chuck 19,99 Result Field1 SumOfField2 Chuck 84,88 Jean 62,09 Mike 34,12 Advice would be appriciated. Cheers, Ludovic Hi You could use a formula like this ...

How many Server-side rules can you put on one mailbox?
I am using Exchange Server 2003 and want to setup 52 rules on one of the mailboxes, is this possible? the hardcoded limit on space for rules is 32K...i doubt you'll be able to get 52 rules on one mailbox... -- Susan Conkey [MVP] "jmareel" <jmareel@discussions.microsoft.com> wrote in message news:6ADDDCD7-948C-415F-B194-1944C9936BC2@microsoft.com... > I am using Exchange Server 2003 and want to setup 52 rules on one of the > mailboxes, is this possible? http://support.microsoft.com/default.aspx?scid=kb;en-us;147298 -- Bharat Suneja MVP - Exchange www.zenpris...

Repair SQL Corrupt database
Hi, I have a corrupt MS SQL Server 2005 database which I am trying to repair using: DBCC CHECKDB ('MYDB', REPAIR_ALLOW_DATA_LOSS) Unfortunately this does not seem to fix anything. After running the repair multiple times, I ran DBCC CHECKDB ('MYDB') WITH NO_INFOMSGS to see if it fixed the corruption, I noticed that is was returning a random amount of errors on each run. Does any know if It is the case that this database is beyond repair? If so will the best approach be to revert back to a non corrupt database backup and then roll forward using Transaction Lo...

Server being used to send out viruses
Problem: When I select "Clients can only submit if homed on this server" in the CONNECTIONS tab in the IMC, my remote POP3 users cannot send email through the server. The email just sits in their Outbox. These POP3 clients do have mailboxes (email accounts) on the server so this should work. When I set my server to ACCEPT CONNECTIONS FROM ANY HOST, my server becomes a target for others (as known as evil people) to use my email server to send out viruses. Any ideas? Thanks, everyone who contributes to this forum. This is great! David Hi, If you are using Exchange, w...

Does a 'grace period' exist for Server CALs??
I am presently planning a new Win2k8 R2 DC/TS/AD/DNS server install. I know the TS/RDS CALs have a "grace period" which allows me time to obtain however many additional CALs we need. Does a similar "grace period" exist for the Server CALs per se?? If I don't have enough Server CALs (device) at the time of setting up the server and people's computers connecting to it via Terminal Services/Citrix, what will happen?? I haven't found anything searching the Internet... Thank you, Tom Hello tom12010, See here about the grace periods depending ...

Is SQL 2000 tran working with VS2008?
I code a store procedure mySP in SQL 2000 in which using transaction. I used two ways to test after saving sp. 1) rename one table or 2) rename column name If I use "exec mySP" in SQL 2000 query window, error will catch but ASP.NET try-catch will catch nothing, it always return no error. Is SQL 2000 tran working with VS2008? -- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 On Feb 5, 10:15=A0pm, "aspfun via DotNetMonster.com" <u53138@uwe> wrote: > I code a store procedure mySP in SQL 2000...

gp10 change clients pointing to different server
In version GP 10 I have clients pointed to a test server. When production server is ready what do i do to point the clients to the production server e.g. GPServer. Would I change the odbc connection? Or Rerun the client installs? Any help is appriciated. Thank YOu As long as your production server has THE SAME level service pack as your clients and THE SAME third party products all you need to do is repoint your ODBC to the production server. Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http://www.maximumglobalbusiness.com "2020" wro...

List Running Horizontally-Pivot Table Possible?
I just had a customer ask this one and I'm not so sure about it. 1) The customer has setup a list of information that is running horizontally instead of the typical list running vertically. 2) I just taught him how to do pivot tables and he wants to generate a pivot table with his "horizontal" list. 3) I know he can copy and paste special and use the Transpose feature to change the list from horizontally oriented to vertically oriented. 4) the question is: can he leave the table in its original orientation and still generate Pivot tables? I can't seem to make it work ...

How do I view all Global Catalog Servers in Active Directory
Guys, Is there a way to view and confirm all the Global Catalog Servers in Active Directory? I'll appreciate your help.Regards. -- Buchi On Sat, 6 Aug 2005 08:21:01 -0700, "Buchi" <Buchi@discussions.microsoft.com> wrote: >Guys, >Is there a way to view and confirm all the Global Catalog Servers in Active >Directory? I'll appreciate your help.Regards. You could in the DNS (dnsmgmt.msc) under the _msdcs folder for your AD domain. or nslookup (ls -t SRV ADdomain.com) or look via Sites and Services or use repadmin: (repadmin /showreps YourDC). The result wi...

Running out of memory
I have some 55 users on an Exchange Server 2003 Std and I am getting a warning 'Out Of Virtual Memory' on the server console. The server has Exchange Server 2003 SP2 installed with 2 GB RAM. The Virual Memory set up is using 'System Managed Size'. I have been running with this config without problems for a few months now. When the message 'Out Of Virtual Memory' appears, no-one can access their mailbox from the clients although the server continues to run OK. The only way that I have been able to resolve this is by rebooting the Exchange Server, which happens ab...

Running an Excel Macro from an Access Command Button
Hi , Can anyone help me with this, I am trying to run an excel macro from an access command button. I want the macro to Bold the Headings on a excel spreadsheet. The code runs without any errors but the macro doesnt seem to work, I think I have got the line ExcelApp.ExecuteExcel4Macro "RUN(""PERSONAL.XLS!BoldHead"")" wrong The code: Private Sub cmdRunMac_Click() Dim ExcelApp As Excel.Application Dim ExcelBook As Excel.Workbook Set ExcelApp = Excel.Application ExcelApp.Visible = True Set ExcelBook = ExcelApp.Workbooks.Open("C:\Documents and Settings\...

Cannot reinstall Exchange 5.5 on Small Business Server 4.5
Our Small Business Server 4.5 crashed yesterday and could only be started by doing a repair of Windows NT. Unfortunately, this left the Small Business Server programs partially installed. Now, Exchange will not start. It has the message "A connection could not be made to the Microsoft Exchange Server". I tried to reinstall Exchange, but get the message "This component is already installed and cannot be modified". Microsoft Exchange does not appear under Add/Remove Programs, so I cannot uninstall it either. Any suggestions would be greatly appreciated. Deborah obxgi...

Need help with update sql plus filter
I have the following update sql (copied from the query design view) UPDATE ListQry SET ListQry.ApprovalStatusID = [Forms]![OpeningForm]![Responsibility] WHERE (((ListQry.ApprovalStatusID)<[Forms]![OpeningForm]![Responsibility] And (ListQry.ApprovalStatusID)>-1) AND ((ListQry.OtherStatusID)>300)) OR (((ListQry.ApprovalStatusID)<[Forms]![OpeningForm]![Responsibility] And (ListQry.ApprovalStatusID)>-1) AND ((ListQry.OtherStatusID) Is Null)); ApprovalStatusID is an integer OtherStatusID is an integer ListQry is the recordsource for my form. I would like to add the f...

Can't get rules to run.
I can't get Outlook 2003 rules to run. I am getting my mail from a pop3 account and would like to have new mail sorted to specific folders when it arrives. I set up the rules as I did in previous versions of outlook, but they do not run automatically. I can run the rules manually and they will move the mail. I have this rule (for example Apply this rule after the message arrive from some@email.address and on this machine only move it to the somefolder folde I have tried deselecting on this machine only Thanks. Do you have an Exchange service in this profile? Are you using Cache...

CRM 3.0 Setup err databases already exist on the specified SQL Ser
ReportServer ReportServerTempDB Question : How to clear this problem? The On-Line Help did not applied as SQL 2005 has been installed on SBS2003 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Microsoft SQL Server Reporting Services Cause There are two causes for this error: Microsoft SQL Server Reporting Services is already installed on the specified server. Setup has found a version of Microsoft SQL Server that is not supported by Microsoft SQL Server Reporting Services. Solution One of the following versions of Microsoft SQL Server are required for Microsoft SQL Server Repor...

7-bit and News Servers
Most of the messages that come here get the following news header fixed into them: Content-Transfer-Encoding: 7bit I recently (15:16 Eastern, 2010.06.02, Wednesday) looked through various messages and noticed that the following people no longer post 7-bit. From: "Larry Serflaten" <serflaten at usinternet dot com> References: <1EDE11CE-8D50-4A18-B59C-95C45B849EFC@microsoft.com> Subject: Re: Instr problem in VB5 Date: Wed, 2 Jun 2010 14:12:35 -0500 Lines: 15 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1983 X-...

removing first exchange server in org
I am ready to move the first exchange 2k3 server from my organization. I have followed the steps in article 822931 and finished them. I am just noticing that one of the public folders - entitled system configuration - is not covered in the instructions in 822931 and is set for replication between the source(server being taken out)and destination server. Should i remove the source server or does it matter. Thanks ...

Outlook Exchange Server #2
How do I set up an exchange server? Do you HAVE an exchange server? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Lloyd asked: | How do I set up an exchange server? ...

CRM server powered down
I have had a power outage in the server room, and the CRM server powered down (not through a standard shutdown). Since rebooting nobody can log in to CRM now. Everybody gets an error message saying "An error has occurred. For more information, contact your system administrator." Can anybody suggest where I begin to fix this? First, check all you sevices such as SQL, CRM Security service, IIS etc are running. It is most likely that the problem lies here after a re-boot. Pete C "Kodak" <Kodak@discussions.microsoft.com> wrote in message news:928445BB-AC24-44A4-...

French check on english server environment
Hi, We currently have an English environment deployed on our server. I'm looking for a way to print check in different languages (French or English). Anybody has this issue? Event is it's not related to check, it could be related to bilingual reports. Thank you Hi Alain, We have a similar situation but with a Spanish vs French issue. This has been quite an ordeal. I have been working with our reseller, but neither them nor Microsoft seems to have a lot of information on how this should work. We are still trying to get all of the proper information to set up a test environ...

3000+ Connections on Exchange Server
Looking further into my Exchange Server 5.5 problems, I checked POP3 access using telnet and that was fine, so I then checked SMTP. It returns a 421 EXCHSRVR connection limit reached message. Ran NETSTAT -an on the EXCHSRVR and redirected the output to a TXT file. The file was over 200KB in length and contained over 3000 connections. Now, I'm not entirely sure what ones I should see and what ones are extra. Can anyone give me some ideas of what I should be seeing in the way of connections on my mail server? yes, that sounds excessive. you can turn on SMTP Protocol Logging (to Me...