Accepted Solution

Unable to pass an array to a custom function

Hello everyone,

I'm stuck while implementing a workflow in our company.

What I would like to achive:

I would like to create a workflow with the following actions:

  1. User enters a server, a SID of an oracle db and the size for arch, data, log
  2. Creation of 3 volumes and qtree according to the data above
  3. Send an E-Mail with the complete "scli disk create" string to the user
  5. Thin-provisioning of the LUNs

What I have done:

  • Copied and Customized the Send Email command
  • Created a custom command for thin provisioning

The commands

Send EMail with CMD

param (

  [parameter(Mandatory=$true, HelpMessage="SMTP server for sending the email item")]



  [parameter(Mandatory=$true, HelpMessage="Recipient's SMTP email address")]



  [parameter(Mandatory=$true, HelpMessage="From field's SMTP email address")]



  [parameter(Mandatory=$true, HelpMessage="Subject of the email item")]



  [parameter(Mandatory=$false, HelpMessage="SMTP port")]


  [int]$SmtpPort = 25,


  [parameter(Mandatory=$false, HelpMessage="Use SSL for secure connection if server demands it")]

  [bool]$UseSsl = $false,


  [parameter(Mandatory=$true, HelpMessage="The command you would like to generate. Either sdcli disk connect or sdcli disk create")]

  [ValidateSet("connect", "create")]



  [parameter(Mandatory=$true, HelpMessage="The Server which the LUNs should be mapped to")]



  [parameter(Mandatory=$true, HelpMessage="Domain, which the server belongs to")]



  [parameter(Mandatory=$true, HelpMessage="The name of the arrays, where the volumes where created")]


  [parameter(Mandatory=$true, HelpMessage="A list the luns to connect/create, like /vol/volumename/qtree/lunname.lun")]



  [parameter(Mandatory=$false, HelpMessage="A list of the size in GB")]



  [parameter(Mandatory=$true, HelpMessage="A list of the mountpoints")]



function ConvertFromSecureToPlain{



        [System.Security.SecureString] $SecurePassword


    # Create a "password pointer"

    $PasswordPointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)


    # Get the plain text version of the password

    $PlainTextPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto($PasswordPointer)

    # Free the pointer


    # Return the plain text password







        throw "FOr Secure Connection user details are mandatory"






    $SMTPCreds = Get-NaCredentials -Host $SmtpHost

    if (!$SmtpUserPassword -and !$SMTPCreds) {

        throw "Could not find SMTP credentials"


    if ($SMTPCreds) {

        if ($SMTPCreds.Username -ne $SmtpUserName)


            throw "Could not find SMTP credentials of user : " + $SmtpUserName



    if ($SMTPCreds) {

        $SmtpUserPassword =  ConvertFromSecureToPlain -SecurePassword $SMTPCreds.Password



if(!$SmtpUserName -and $SmtpUserPassword)


    throw "Missing credentials information"


$smtpClient = New-Object System.Net.Mail.SmtpClient

$mailMessage = New-Object System.Net.Mail.MailMessage

$ = $SmtpHost







    throw "'To' value is not in the SMTP address format"




    $mailMessage.from = $From




    throw "'From' value is not in the SMTP address format"


if( -not (-not $SizeList -or (($LunList.length -eq $SizeList.length) -and ($LunList.length -eq $MountList.length))))


          throw "LunList, SizeList and MountList must have the same amount of values"


$mailMessage.Subject = $Subject

#$mailMessage.Body = "Email from WFA system:`n"

#$mailMessage.Body += "Workflow Name = “ + $(Get-WfaRestParameter "workflowName") + "`n"

#$mailMessage.Body += "Workflow ID = “ + $(Get-WfaRestParameter "workflowId") + "`n"

#$mailMessage.Body += “Command Name = " + $(Get-WfaRestParameter "commandName") + "`n"

#$mailMessage.Body += “Job ID = " + $(Get-WfaRestParameter "jobId") + "`n"

#$mailMessage.Body += “Workflow executed by User = " + $(Get-WfaRestParameter "userName") + "`n"

# Customized by ABuchmann

$mailMessage.Body += "Führe folgende Zeilen auf dem Server " + $Server + " aus: `n`n"

for($i=0;$i -lt $LunList.Length;$i++)


          $Cmd  = "sdcli disk  " + $Action + " -d " + $MountList[$i] + " -p " + $Controller + ":" + $LunList[$i] + " -I %computername%" + $DomainName + " -dtype dedicated"

          if($Action -eq "create")


                    $Cmd += " -rs n -z " + $SizeList[$i] + "GB"


          $mailMessage.Body += $Cmd + "`n"


$mailMessage.IsBodyHtml = $False



    $smtpClient.Credentials = New-Object System.Net.NetworkCredential($SmtpUserName, $SmtpUserPassword);


$smtpClient.Port = $SmtpPort

$smtpClient.EnableSsl = $UseSsl

Get-WFALogger -Info -message $("Sending email to " + $To)


I tested the command above with the "Test"-Button in the "Command Definition"-window. Everything works fine, I can pass arrays to the variable $LunList, $SizeList, $MountList by separating the values using a comma and I am able to send/receive the mail.

But when I try to use the command inside of my workflow, I'm definitly not able to pass comma separated values to the command. it always fails with the following error:

Illegal expression: "/vol/" + + "/" + + "/" + + ".lun","/vol/" + + "/" + + "/" + + ".lun","/vol/" + + "/" + + "/" + + ".lun"

At command 'Send Email with CMDs', tab 'Parameters', property 'LunList'

I also tried to pass a string list like "vol1", "vol2", "vol3" but I received the same error.

Is there a limitation with array?

It would be nice to use the "Send Email with CMDs"-Command because like that, it can be used for multiple Workflows with a different amount of LUNs

Kind regards,


Re: Unable to pass an array to a custom function

Hello Adrian,

       I haven't tried your command code but l think I know the problem. Can you try providing double // instead of a single / in the Parameters in the workflow. I think this should work.

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: Unable to pass an array to a custom function

Hi Adrian,

Well, I attempted your command in my setup and when I passed from the workflow the following string. Worked in preview. Did not try execution however.

"/vol/" + + "/" + + "/" + + ".lun,/vol/" + + "/" + + "/" + + ".lun,/vol/" + + "/" + + "/" + + ".lun"

The difference between your parameter input and this one is that the comma between different lun names is within the quotes.



Re: Unable to pass an array to a custom function

You are right. Thank you!

May you also know more about the following issue:

If I use the function above to pass multiple volumes to the send-email-param. I sometimes have the problem that the value like

"/vol/" + + "/" + + "/" + + ".lun,/vol/" + + "/" + + "/" + + ".lun,/vol/" + + "/" + + "/" + + ".lun,/vol/" + + "/" + + "/" + + ".lun"

is too long. I can add it to a command, but I'm unable to save the workflow as I always receive the following error:

Is there a reason why there's a limit of 256 characters per field? Is there a way to set a highter limit?

Re: Unable to pass an array to a custom function

Hi Adrian,

I assume you are referring to each individual field in  this screenshot which is about providing values to specific command parameters in the workflow design.

If yes, you are right that the limit is 255 characters in WFA releases of 2.0 and 2.0.1.

This has been fixed in the upcoming release of WFA 2.1. We were able to expand that limit to 2000 characters as of now.

WFA 2.1 will be available shortly.