Start-process notepad | stop-process
pretty much all I know what to do.
Start-Process just starts a process; it does not provide a way to reference that process after it has been started. Another way to do it would be:
# // Declare an array to hold Process IDs
$aProcessIDs = @()
# // Create a Wscript.Shell object to use for running processes
$oWshShell = New-Object -ComObject Wscript.Shell
# // Start 10 instances of notepad
for ($i=1;$i -le 10;$i++)
{
# // Run notepad.exe
$oProcess = $oWshShell.Exec('notepad.exe')
# // Add the ProcessID of the running process to the array
$aProcessIDs += $oProcess.ProcessID
}
# /// Wait 10 seconds
Start-Sleep -s 10
# // Terminate all processes
foreach ($iProcessID in $aProcessIDs)
{
Stop-Process -Id $iProcessID
}