Get value from inside powershell script

Simple question, I run a powershell script to check if a file exist in my drive.
The result (true or false) should be save in a variable.
Can I do this? how?
I tried like this but doesn’t work
{
“Command”: “XRunAndWait”,
“Target”: “powershell.exe”,
“Value”: “-executionpolicy bypass -File “E:\Joaquin\Escritorio\uivision\scripts\archivo_existe.ps1” -Archivo “E:\Joaquin\Descargas\notas a facturar fix2.csv” -Resultado ${existe_lista}”,
“Description”: “”
}

In your PS script you can save the true/false to the clipboard using Set-Clipboard and then in UI.Vision read it with ${!clipboard}

Clipboard is a good idea.

Other ideas:

  • Use the ${xrun_exit} variable. So if you close the Powershell VBS script with WScript.Quit 5, then in the macro ${xrun_exit} will have this value! (here: 5).
    Edit: VBS code is WScript.Quit 5, Powershell is simply exit 5

  • Save the data as CSV file and then use csvRead (useful if a lot of data needs to be imported)

thank you for all your ideas.
I will try with the ${xrun_exit}

I do as yo said, inside the script I end it with WScript.Quit 23
But in the macro ${!xrun_exitcode} value’s is 0

What I’m missing?

The script is powershell and I run it with xrunandwait

{
  "Command": "XRunAndWait",
  "Target": "powershell.exe",
  "Value": "-executionpolicy bypass -File \"E:\\Joaquin\\Escritorio\\uivision\\scripts\\archivo_existe.ps1\" -Archivo \"E:\\Joaquin\\Descargas\\notas a facturar fix2.csv\"",
  "Description": ""
}

Ah, my mistake. The code above is for VBS.

For Powershell exit codes use exit 5