Is it possible to call powershell cmdlets asynchronously?
asynchronous, powershell
Solution
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:
- Split-Job
Problem
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?