Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - is it possible to create async processes?

Reply
 
Old 04-11-2007   #1 (permalink)
Frank


 
 

is it possible to create async processes?

Hi,

Is is possible to create async processes in Powershell via WMI or .NET? If
so, can someone give an example? I would like to spawn off Powershell
scripts at the same time to gather performance information from various
hosts. I have the PS scripts written for gathering this data but I just need
to spawn them at the same time for comparison purposes.

thanks in advance,

Frank


My System SpecsSystem Spec
Old 04-11-2007   #2 (permalink)
Duncan Smith


 
 

Re: is it possible to create async processes?

On Apr 11, 7:48 pm, Frank <F...@discussions.microsoft.com> wrote:
> Hi,
>
> Is is possible to create async processes in Powershell via WMI or .NET? If
> so, can someone give an example? I would like to spawn off Powershell
> scripts at the same time to gather performance information from various
> hosts. I have the PS scripts written for gathering this data but I just need
> to spawn them at the same time for comparison purposes.
>
> thanks in advance,
>
> Frank


I'm going to stick my neck out here and say that you're options may be
limited, if only because Powershell itself is single-process single-
threaded. However there's always Start-Process which would be
asynchronous in as much as control will pass back to the calling
powershell session as soon as the child-process is started. Then
maybe you can watch/poll/monitor the file-system for results?

Regards,

Duncan.

My System SpecsSystem Spec
Old 04-11-2007   #3 (permalink)
Frank


 
 

Re: is it possible to create async processes?

I don't see Start-Process as any command or cmdlet?



"Duncan Smith" wrote:

> On Apr 11, 7:48 pm, Frank <F...@discussions.microsoft.com> wrote:
> > Hi,
> >
> > Is is possible to create async processes in Powershell via WMI or .NET? If
> > so, can someone give an example? I would like to spawn off Powershell
> > scripts at the same time to gather performance information from various
> > hosts. I have the PS scripts written for gathering this data but I just need
> > to spawn them at the same time for comparison purposes.
> >
> > thanks in advance,
> >
> > Frank

>
> I'm going to stick my neck out here and say that you're options may be
> limited, if only because Powershell itself is single-process single-
> threaded. However there's always Start-Process which would be
> asynchronous in as much as control will pass back to the calling
> powershell session as soon as the child-process is started. Then
> maybe you can watch/poll/monitor the file-system for results?
>
> Regards,
>
> Duncan.
>
>

My System SpecsSystem Spec
Old 04-11-2007   #4 (permalink)
William Stacey [C# MVP]


 
 

Re: is it possible to create async processes?

One easy way in this case is just start multiple powershell.exe's.
powershell -noexit "script.ps1"
powershell -noexit "script2.ps1"
....
You could also write a cmdlet and do some threading stuff with multiple
runspaces I guess and gather results.

--
William Stacey [C# MVP]
PCR concurrency library: www.codeplex.com/pcr
PSH Scripts Project www.codeplex.com/psobject


"Frank" <Frank@discussions.microsoft.com> wrote in message
news:E04F3814-CCCC-4A7C-8FD2-818D913A7AD0@microsoft.com...
| Hi,
|
| Is is possible to create async processes in Powershell via WMI or .NET?
If
| so, can someone give an example? I would like to spawn off Powershell
| scripts at the same time to gather performance information from various
| hosts. I have the PS scripts written for gathering this data but I just
need
| to spawn them at the same time for comparison purposes.
|
| thanks in advance,
|
| Frank
|


My System SpecsSystem Spec
Old 04-11-2007   #5 (permalink)
John Vottero


 
 

Re: is it possible to create async processes?

"Frank" <Frank@discussions.microsoft.com> wrote in message
news:B32BFACF-6195-4B83-B03E-234C46723536@microsoft.com...
>I don't see Start-Process as any command or cmdlet?


Start-Process is part of the PowerShell community extensions. See:

http://www.codeplex.com/PowerShellCX


>
>
>
> "Duncan Smith" wrote:
>
>> On Apr 11, 7:48 pm, Frank <F...@discussions.microsoft.com> wrote:
>> > Hi,
>> >
>> > Is is possible to create async processes in Powershell via WMI or .NET?
>> > If
>> > so, can someone give an example? I would like to spawn off Powershell
>> > scripts at the same time to gather performance information from various
>> > hosts. I have the PS scripts written for gathering this data but I
>> > just need
>> > to spawn them at the same time for comparison purposes.
>> >
>> > thanks in advance,
>> >
>> > Frank

>>
>> I'm going to stick my neck out here and say that you're options may be
>> limited, if only because Powershell itself is single-process single-
>> threaded. However there's always Start-Process which would be
>> asynchronous in as much as control will pass back to the calling
>> powershell session as soon as the child-process is started. Then
>> maybe you can watch/poll/monitor the file-system for results?
>>
>> Regards,
>>
>> Duncan.
>>
>>


My System SpecsSystem Spec
Old 04-16-2007   #6 (permalink)
Trevor Sullivan


 
 

Re: is it possible to create async processes?

Frank wrote:
> Hi,
>
> Is is possible to create async processes in Powershell via WMI or .NET? If
> so, can someone give an example? I would like to spawn off Powershell
> scripts at the same time to gather performance information from various
> hosts. I have the PS scripts written for gathering this data but I just need
> to spawn them at the same time for comparison purposes.
>
> thanks in advance,
>
> Frank
>


I'm not exactly a Powershell guru, in fact, I know very little about it,
however I am aware that it is built on .NET. I am wondering if you could
create a .NET delegate and call your Powershell function through the
delegate? Delegates are asynchronous and spawn off their own threads, so
theoretically, this would solve that issue. A while back, I actually
wrote a small, multi-threaded .NET app that used delegates to get
information from remote systems for the same purpose. My guess is that
Powershell ought to be able to do the same thing.

Trevor
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
RAS ASYNC Adapter? Network & Sharing
Design for async call .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46