PowerTip: Use PowerShell to Start a Bunch of Processes

Summary: Learn how to start a bunch of processes by using Windows PowerShell.           

Hey, Scripting Guy! Question How can I use Windows PowerShell to start a whole bunch of processes for testing purposes on one of my systems?

Hey, Scripting Guy! Answer Use a Windows PowerShell range operator, such as 1..10, to specify how many processes you want to create.
           Then pipe the results to the Foreach-Object cmdlet, and in the script block, use Start-Process to create
           the commands you need. Here is an example:

1..10 | Foreach {Start-Process notepad}

You can simplify this command by using % for Foreach, and by simply calling the executable:

1..10 | % { notepad}

To check how many processes you created, use the Get-Process cmdlet:

(Get-Process notepad).count

Comments (0)

Skip to main content