I am running powershell script from c#.
string scriptPath = "/script/myscript.ps1";
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(scriptPath);
Collection<PSObject> results = pipeline.Invoke();
for example if my myscript.ps1 file below;
$test=4
$test++
$test
How to get the variable test value after executing the script. I need to get that value to my c# program.