Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Data Warehousing
»
Integration Services
»
Help: Execute Process Task --> Powershell...
Help: Execute Process Task --> Powershell Command
Rate Topic
Display Mode
Topic Options
Author
Message
BobMcC
BobMcC
Posted Wednesday, March 09, 2011 10:21 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Monday, May 20, 2013 12:51 PM
Points: 167,
Visits: 492
I occasionally run a Powershell command that add characters at the end of each line in a text file.
From a Powershell prompt I run the following command:
(get-content "C:\Some Folder\someFile.txt")| foreach-object{$_+"xxxxx"}|set-content "C:\Some Folder\someFile.txt"
I tried to set that up to run from an Execute Process Task, but I'm not doing something right.
I put the the powershell command in the Executable section and the remainder of the the command in the Arguments section, but I don't have it delimited or quoted correctly (I think).
If I execute the above from a DOS command prompt i.e.
c:\>PowerShell (get-content "C:\Some Folder\someFile.txt")| foreach-object{$_+"xxxxx"}|set-content "C:\Some Folder\someFile.txt"
I receive the following error: 'foreach-object{$_+"xxxxx"}' is not recognized as an internal or external command, operable program or batch file.
Suggestions?
Post #1075700
Koen Verbeeck
Koen Verbeeck
Posted Wednesday, March 09, 2011 12:41 PM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 2:11 AM
Points: 9,378,
Visits: 6,473
You can run Powershell commands from SQL Server Agent. Is that an option?
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1075826
BobMcC
BobMcC
Posted Thursday, March 10, 2011 11:53 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Monday, May 20, 2013 12:51 PM
Points: 167,
Visits: 492
I suppose it would be an option, but why would I want to? I just want to run a single command line utility, not much different than using the Execute Process Task to run a command line option to unzip a compressed file.
I recently found out solution: in the Arguments box i put:
"(get-content 'C:\YetAnotherFolder\MyFile.txt')| foreach-object{$_+',,,,,,,,,'}|set-content 'C:\YetAnotherFolder\MyFile.txt'"
and it looks like it works perfectly.
Post #1076479
Koen Verbeeck
Koen Verbeeck
Posted Thursday, March 10, 2011 12:06 PM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 2:11 AM
Points: 9,378,
Visits: 6,473
BobMcC (3/10/2011)
I suppose it would be an option, but why would I want to?
Well, I don't really see a difference between running a SQL Server Agent job or running an SSIS package.
Both are a means to an end.
Anyway, glad you found a solution.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1076493
BobMcC
BobMcC
Posted Thursday, March 10, 2011 12:28 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Monday, May 20, 2013 12:51 PM
Points: 167,
Visits: 492
Koen Verbeeck (3/10/2011)
BobMcC (3/10/2011)
I suppose it would be an option, but why would I want to?
Well, I don't really see a difference between running a SQL Server Agent job or running an SSIS package.
Both are a means to an end.
Anyway, glad you found a solution.
Koen, On reflection my question about why I would want to, may have sounded snotty and I hope you know I didn't mean it that way. I was genuinely asking why I might want to use an Agent job, in case I was missing something. To explain why I wanted it into an SSIS task is because it's but one task of several related tasks in an SSIS solution I'm building, but I didn't add that as I didn't feel like it was part of the problem.
Thanks for the reply.
Post #1076515
Koen Verbeeck
Koen Verbeeck
Posted Thursday, March 10, 2011 12:33 PM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 2:11 AM
Points: 9,378,
Visits: 6,473
Don't worry, I'm not easily offended
It does indeed make sense to incorporate it in SSIS if it is part of a bigger solution.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1076519
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.