Hi @francoisbnc
Assuming you want to pass an array of variables between WFA commands within a workflow (without using the Add-WfaWorkflowParameter cmdlet) and you are exporting those variables to file locally on your WFA server, then the file name would need to be constant to ensure all the commands in your WFA workflow read the content from the same file name. To achieve that you might consider using the workflow ID as the file name as this is a unique identifier. EG
$workflowID = $(Get-WfaRestParameter "workflowId")
Also you might consider using a system environment variable or reading the registry to determine the file path (or the install location of WFA) as a path to save any temporary files.
Something like this:
#'------------------------------------------------------------------------------
#'Enumerate the WFA install path from the registry
#'------------------------------------------------------------------------------
[String]$registryPath = "hklm:\system\currentcontrolset\services\na_wfa_srv";
[Int]$workflowID = $(Get-WfaRestParameter "workflowId")
Try{
[System.Object]$result = Get-ItemProperty -Path $registryPath -ErrorAction Stop
[String]$wfaExeSpec = $result.ImagePath.Split("/")[0].Trim() -Replace("""", "")
[String]$wfaServicePath = $wfaExeSpec.SubString(0, $wfaExeSpec.LastIndexOf("\"))
[String]$installPath = $wfaServicePath.SubString(0, $wfaServicePath.LastIndexOf("\"))
Get-WFALogger -Info -Message "Enumerated WFA installation Path from Registry key ""$registryPath"" as ""$installPath"""
}Catch{
Get-WFALogger -Error -Message $("Failed Reading Registry Path ""$registryPath"". Error " + $_.Exception.Message)
Throw "Failed Reading Registry Path ""$registryPath"""
}
#'------------------------------------------------------------------------------
#'Ensure the workflows XML file exists.
#'------------------------------------------------------------------------------
[String]$fileSpec = "$installPath\$workflowID.xml"
If(Test-Path -Path $fileSpec){
Get-WFALogger -Info -Message "Reading WFA workflow XML file ""$fileSpec"""
}Else{
Throw "The WFA workflow XML file ""$fileSpec"" does not exist"
}
#'------------------------------------------------------------------------------
Assuming you are creating custom WFA commands, each command can enumerate the current workflow ID and hence read from the correct configuration file which will ensure a uniquie file is created and read from for each workflow in the scenario where the workflow is being executed multiple times as the ID will always be unique.
Hope that helps
/Matt
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.