I want to pass 3 parameter from c# to powershell function but the output it show all parameter in same line. How to fix it ?
This is powershell code
param (
    [string] $param1,
    [string] $param2,
    [string] $param3
)
# begin
function AddStuff($x, $y ,$z) 
{ 
   "x: $x;" 
   "y: $y;"
   "z: $z;"
}
AddStuff $param1, $param2, $param3
# end
This is c# code.
    RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
    Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
    runspace.Open();
    RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
    Pipeline pipeline = runspace.CreatePipeline();
    string scriptfile = @"C:\Users\test2.ps1";
    Command myCommand = new Command(scriptfile);
    CommandParameter testParam1 = new CommandParameter("param1", "paramvalue1");
    CommandParameter testParam2 = new CommandParameter("param2", "paramvalue2");
    CommandParameter testParam3 = new CommandParameter("param3", "paramvalue3");
    myCommand.Parameters.Add(testParam1);
    myCommand.Parameters.Add(testParam2);
    myCommand.Parameters.Add(testParam3);
    pipeline.Commands.Add(myCommand);
    Collection<PSObject> results = pipeline.Invoke();
    StringBuilder stringBuilder = new StringBuilder();
    foreach (PSObject obj in results)
    {
        stringBuilder.AppendLine(obj.ToString());
    }
    MessageBox.Show(stringBuilder.ToString());
when I run it show MessageBox like this.
   x: paramvalue1 paramvalue2 paramvalue3; 
   y: 
   z: 
That is wrong. Why it not show like this.
   x: paramvalue1 ; 
   y: paramvalue2 ;
   z: paramvalue3 ;
 
     
    