Say i have cmdlet1 and cmdlet2, both are long running tasks. Normally i would have a batch file which calls the two cmdlets in order:
call powershell cmdlet1
call powershell cmdlet2
Is there anyway to set them off asynchronously?
Say i have cmdlet1 and cmdlet2, both are long running tasks. Normally i would have a batch file which calls the two cmdlets in order:
call powershell cmdlet1
call powershell cmdlet2
Is there anyway to set them off asynchronously?
Try:
cmd.exe /c call powershell cmdlet1
cmd.exe /c call powershell cmdlet2
If you're on PowerShell 2, you can use background jobs.
From the help:
about_Jobs
When you start a background job, the command prompt returns immediately, even if the job takes an extended time to complete. You can continue to work in the session without interruption while the job runs.
So you can use
Start-Job -ScriptBlock { cmdlet1 }
Start-Job -ScriptBlock { cmdlet2 }
However, you need to have PowerShell configured for remoting, even when running a job locally.
I also stumbled over this:
If you have to stay on v1, try seeing if you can use the PSEventing snap-in: http://pseventing.codeplex.com/