Victor92
Contributor
Contributor

Orchestrator + powershell script : variable

Jump to solution

Hi,

I want create a workflow with an external script powershell and "scriptable task".

First step :

1. i set my input parameters in "Scriptable task"  and set in "scripting" tab my variable input for the external script powershell : scriptArgs = Variable1 + " " + Variable2;

2. i get my variable in my external first script powershel --> at this step it's OK

3. in my external first script powershell, i create variables $var1 and $var2

Second step :

1. I create a "Scriptable task" and i want get powershell output ($var1 and $var2) in input for my "scriptable task"

I don't know how passing a powershell variable to other "workflow element" or "scriptable task"

Tags (2)
1 Solution

Accepted Solutions
igaydajiev
VMware Employee
VMware Employee

Invoke an External PS script workflow returns as output objects of type PowerShell:PowerShellRemotePSObject.

You can use it to extract data from the powershell script output. Example is provided together with the plugin inside folder Library/PowerShell/Samples/List directory content workflow

you can use PowerShell:PowerShellRemotePSObject to receive the output in form of raw xml PowerShell:PowerShellRemotePSObject.getXml() or using getRootObject() directlyas objects of type PowerShellPSObject and then to use getProperty(xxx) ...


Here is snippet from sample workflow for traversing folder list returned as result of invocation of ps script .

  // Get PowerShellRemotePSObject

  var psObject = invResult.getResults();

  var directories = psObject.getRootObject();

  var isList =  directories instanceof Array

  if ( isList ){

  for (idx in directories){

  var item = directories[idx];

  if ( item.instanceOf('System.IO.FileInfo') ){//check type of object

  System.log( item.getProperty('FullName') );//extract value from result

  }

  }

  } else {

  System.log( directories.getProperty('FullName') );//extract value from result

  }

  }

...

View solution in original post

0 Kudos
3 Replies
igaydajiev
VMware Employee
VMware Employee

Not sure I understand the question.
Could you provide sample workflow?

0 Kudos
Victor92
Contributor
Contributor

My workflow : First Step

pastedImage_0.png

In scriptable task :

pastedImage_2.png

pastedImage_3.png

In "invoke an external script" : I link "arguments" with "scriptArgs" and write "param ($Name, $IP)" at the first line of my script ps1.

Script ps1 :

pastedImage_19.png

At this step, it's OK, i get my variable $Name et $IP in my script powershell.

Now, i want get my variable $var1 and $var2 in input for a second "scriptable task" but i don't know how passing variables

pastedImage_20.png

0 Kudos
igaydajiev
VMware Employee
VMware Employee

Invoke an External PS script workflow returns as output objects of type PowerShell:PowerShellRemotePSObject.

You can use it to extract data from the powershell script output. Example is provided together with the plugin inside folder Library/PowerShell/Samples/List directory content workflow

you can use PowerShell:PowerShellRemotePSObject to receive the output in form of raw xml PowerShell:PowerShellRemotePSObject.getXml() or using getRootObject() directlyas objects of type PowerShellPSObject and then to use getProperty(xxx) ...


Here is snippet from sample workflow for traversing folder list returned as result of invocation of ps script .

  // Get PowerShellRemotePSObject

  var psObject = invResult.getResults();

  var directories = psObject.getRootObject();

  var isList =  directories instanceof Array

  if ( isList ){

  for (idx in directories){

  var item = directories[idx];

  if ( item.instanceOf('System.IO.FileInfo') ){//check type of object

  System.log( item.getProperty('FullName') );//extract value from result

  }

  }

  } else {

  System.log( directories.getProperty('FullName') );//extract value from result

  }

  }

...

0 Kudos