Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
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 !
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900