I'm trying to run a bunch of powershell script files one by one through a c# winform application using Process.Start(). Whenever I start a powershell for a scriptfile, it creates a new Powershell Process and runs a script file.
The problem with this is that, i'm not able to hold onto one single session so that I can use the variables initialized by the first script file in the second script file.
There are two ways to do it.
Method 1 :
Start multiple powershells using the same session
Method 2 :
Or pipe commands in to the powershell window so that I can have only one Powershell and run all script files in the same powershell thereby having only one session
Please let me know how to do Method1 or Method2
Thanks for your help in advance !