Click here to Skip to main content
11,711,440 members (85,087 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# PowerShell
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 4-Aug-11 9:18am

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 529
1 OriginalGriff 200
2 Peter Leow 164
3 Abhinav S 125
4 CHill60 115
0 Maciej Los 95
1 Richard MacCutchan 90
2 Abhinav S 90
3 OriginalGriff 80
4 Member 4653839 50


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 4 Aug 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100