Zdroje informací pro profesionály v oboru IT >
Domovská stránka fór
>
Windows PowerShell
>
Running module function in different run-space
Running module function in different run-space
- Hi AllI am trying to create a buildscript in powershell. I'm using Psake (http://code.google.com/p/psake/, the V2 branch) as my build engine. Psake is a Rake MsBuild like build tool and it has all kinds of useful functions / methods for creating build scripts. The problem I have is that I have one build script calling another build script. Unfortunately it seems that upon calling the run-psake function all the variables in use for the first call are re-used. For instance there are several collections which keep track of which actions to perform. As soon as the second build script finishes these collections get cleaned out and then the first build script fails because the collections have been removed.So in order to fix this problem I'm thinking of pushing each invokation of the run-psake script into a different runspace. I've tried to invoke powershell.exe and send a run-psake command into that powershell. Unfortunately it doesn't really seem to work. I get all kinds of errors and in the end my master process still errors out.Now the questions are:- How do I achieve this form a powershell script. aka how do I create a new runspace in powershell. If that is not possible I'll take C# code too :)- How can I make the second (or third or ...) runspace put it's output into the console that was used for the first runspace. I would like updates on the status of the process because the build process takes quite a long time and it would be good to get updates on progress.ThanksPatrick
Všechny reakce
- You'll looking for ways to start things in a new runspace...
If you're using v1:
http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!130.entry
If you're using v2 (currently CTP3):
PS>get-command *-job
Now, I'm tired tonight, and don't know if that fully helps you or not... - Hi MarcoThanks heaps for that answer. I am on V2 CTP3 so I had a look at the start-job command but unfortunately that requires the WinRM service. I found a link to the CTP for that but there are only installs for vista and server 2008. Unfortunately I'm still on an xp machine so that doesn't work :(I've had a look at the blog post describing the solution for powershell v1 but so far I haven't been able to make heads or tails out of it. I'll go back and study it some more to see if I can get it to work on my machine. In the mean time if there are any other solutions I'm open to suggestions.In any case thanks for your help!RegardsPatrick
- I'd expect a WinRM 2.0 release for XP/2003 (so that PowerShell v2 remoting and jobs work) by end of year...
I will try to detail today or tomorrow how to use that v1 solution if you're having problems using that info...

