Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Can't execute CMD / Powershell scripts from Workflow project with errors

Created: 24 Jun 2013 • Updated: 10 Jul 2013 | 12 comments
bkcbkc11's picture
This issue has been solved. See solution.

Hi All

I doing a VMware deployment project of VM's from a workflow.

I have done some SQL integration to pull data from vCenter, so far so good.

The workflow generate a CMD file and save to disk with alot parameters to pass to a powershell script, which is executed from the workflow generated CMD file. Works fine. All is generated correctly.

I tried out the WF generated CMD to run it by hand, everything is working perfectly. The VM is deployed as it should be.

My problem is to execute this CMD file from workflow:

1 -I tried "Execute Batch" : Result PowerShell hangs in the of the script.

2 -Then tried "Execute Process and Wait" : Result script is running OK, but workflow throw an application error.

Standard Error has been checked and checked

Runned with cmd.exe / c ... and without

No luck.

The CMD is a simple script:

PowerShell.exe - file c:....\NewVM.ps1 para1 para2  ..... para15

 

A simple thing, but giving a lot of grey hairs.

Can someone help me FAST, PLEASE.

Thanks in advance :o)

BR bkcbkc11

 

Operating Systems:

Comments 12 CommentsJump to latest comment

reecardo's picture

Try specifying the full path to CMD.EXE or Powershell.EXE (i.e. C:\Windows\System32\CMD.EXE)

bkcbkc11's picture

Hi ReeCardo

I tried that i all sorts of variations, but no luck.

Thanks for the fast response.

BR bkcbkc11

b3tts32's picture

I have powershell working using the Execute Process and wait component. On the file name option I have the full path to the powershell.exe "c:\windows\system32\windowspowershell\v1.0\powershell.exe" and under the argument field I have the full path to the .ps1 file created. 

 

I would also double check your execution policy on the server to make sure it's remote signed or unrestricted.

reecardo's picture

Just another note on this... the Execute Process/Execute Process and Wait components are basically just "wrappers" for the Process and ProcessStartInfo classes in .NET's System.Diagnostics. If you google "ProcessStartInfo powershell", you'll see some C# examples of people getting it to work in C#.

You can then translate the arguments and stuff to your inputs to the components.

bkcbkc11's picture

Hi All

I tried b3tts32 suggestion, and all parameters are passed fine to the ps1.

The virtual machine is created completly as specified in workflow, but after ps1 script has finished the workflow goes into application error.

log file says the following.

Error,25. juni 2013 08:52:23,System.Threading.ThreadAbortException: Thread was being aborted.
   at LogicBase.Core.ExecutionEngine.AbstractExecutionEngine.RunComponent(TLExecutionContext context, IData data, IOrchestrationComponent comp)
   at LogicBase.Core.ExecutionEngine.AbstractExecutionEngine.RunEngine(List`1 executionQueue)

 

bkcbkc11's picture

I have tested some more.

I changed the powershell script to a simple "echo script", then it runs fine.

I seems like a timeout error of some kind.

During the run assignment of to disk of VM the workflow goto an error, but the script continue to run as normal. So the error occurs in the middle of a powershell script line, where no powershell error occurs.

The component doesn't give any option to set timeout time

reecardo's picture

If you've got this running in a Workflow type project, drop a "Switch Workflow to Async" component at the start of the flow. It may help with the timeout issues.

If your project is really just a "workhorse" and there's no tasks (or actual workflow specific items) in it, move everything to a Decision project. Or you can deploy the Decision as an EXE and have a workflow project invoke that (if you do have workflow items). You have a few options to get around the timeout if you have to.

bkcbkc11's picture

I dropped the idea of using script inside workflow, now it's getting way to complicated.

I very sad that workflow should give so much headache for a simple script to execute.

Will try to use server side task generated from workflow.

The server task is now generated fine.

Only the execution of the task missing.

Need some valid XML to input to execution component.

The client side task XML in the related video, doesn't work with server side task

Anyone know how this should look.

b3tts32's picture

Hi bkc,

 

Which project type are you using? Webform or workflow? Also, on your execute process and wait do you have the standard output option checked? You can drop me a line if you want and we can hop on a webex and see if we can get it figured out.

bkcbkc11's picture

I use a webform project since I don't need any process manager tasks to be involved in the deployment of the VM.

I have tried all combinations of standard output options, no luck there.

Tommorow I will go down another lane. Using Altiris Task server to execute.

- I have allready made a dynamic way of creating a server side script task from workflow.

- Manually executing this task from the console work perfectly.

- Now i'm just need to get the execute task component to work properly in WF.

I think it's something about the inputXML string, I need to change from the example thats in a video in here.

So I need to figure out, how Execute Task webservice work for a server side script task compared with the client side script task. Any suggestions ?

bkcbkc11's picture

Problem solved:

If the collection part is removed from XML string, then server side script works.

XML input should look like this:

<inputParameters>
 <parameter>
<name>@CompRequirements</name>
 <value>
<minWaitTime>1 minutes</minWaitTime>
<maxWaitTime>1 minutes</maxWaitTime>
<minCompletion>1 %</minCompletion>
</value>
 </parameter>
 </inputParameters>

Now the deployment of VM is stable and works every time.
 

bkcbkc11's picture

The actual problem wasn't anything about tasks or execute process component.

It's was about the  default executetimeout in web.config that was exceeded.

The default is 110 seconds and my workflow project runs for 45 minuttes at least.

I added the executetimeout to 3600 seconds after publishing my project.

Problem solved.

SOLUTION