Page 1 of 1

Run Powershell from Execute Stage

Posted: Wed Jun 25, 2014 3:51 am
by mgsteiner
Hello Guys,
I 'm having problems when I want to execute a powershell Script remote from an Execute Stage or in a routine using CALL DSEXECUTE.

So, the script ist to execute Db Backups locally on the remote server and it works just fine when I run it from my CMD or PS shell.
Nevertheless, when I do the same execution in Designer does not work.

Does anybody knows I to run a powershell Script in Ds 8.7?,
is there any previous setting to do?

Thanks a lot in advance
Max

Posted: Wed Jun 25, 2014 5:23 am
by dsetlteam
What is the error that you are getting?

Note - In the Execute Command Activity, prefix powershell.exe before executing your script.

For example, if you want to execute script namely "abcd.ps" then in the command activity put up the following :-

powershell.exe abcd.ps

Posted: Wed Jun 25, 2014 5:26 am
by ArndW
Could you post how you call it up from the command line manually and how you call it from DataStage? Please also include the error message.

Posted: Wed Jun 25, 2014 6:48 am
by mgsteiner
From the command line (CMD): powershell -File Script1.ps1 (works good)
From Powershell : .\Script1.ps1 (works also good)

In DS Execute Command Stage :
- Command = powershell
- Parameters = -File <scriptpath>\script1.ps1

Error:
---------------
Backup_Test..JobControl (@Execute_Command_1): Executed: powershell -File <scriptpath>\script1.ps1
Reply=0
Output from command ====>
Invoke-Command : An internal error occurred.
At <scriptpath>\script1.ps1:6 char:15
+ invoke-command <<<< -computerName <server1> -Credential $Cred -ScriptBlock {
& '<ServerScriptPath>\script2.ps1' par1 par2 par3}
+ CategoryInfo : InvalidOperation: (:) [Invoke-Command], PSInvali
dOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.I
nvokeCommandCommand
-------------------------

Can it be credentials problems ?
Even if I want to execute a normal (powershell get-help) also does not work.

Any idea?

Thanks a lot in advance

Posted: Wed Jun 25, 2014 6:51 am
by mgsteiner
chulett wrote:Note that this is not the Execute Command stage but rather the Execute stage which is unique to a Windows server install. Not the same animal.
Thanks for the reply, but I dont understant to whom you call animal.

Anyway, Yes, I have Server Edition in a Windows System installed and I see the name of the Stage is Execute Command

Posted: Wed Jun 25, 2014 6:59 am
by chulett
I removed my post after you answered with your details as I was obviously wrong. I was basing my assumption on the wording in your initial post and the fact that you were on Windows, never mind that it is very early in the morning for me. There is an actual stage named the Command Stage which only comes with Windows and which tends to confuse people. Case in point, me. :wink:

And all I meant by they are "not the same animal" is that the two stages are different.

Posted: Wed Jun 25, 2014 7:03 am
by chulett
mgsteiner wrote:Can it be credentials problems ?
Looks like that may be the case. Check the last post in this thread and see if that helps.

Posted: Thu Jun 26, 2014 5:08 am
by ArndW
I see you are using a relative path to the command file. The working directory for DataStage commands is set to the project directory, so perhaps it is a path issue. You can copy "script.ps1" to the project directory to test that.