The “Start-Job” module is used to start a background job without interacting with the current session on the local computer in PowerShell. When users start a job in the background, its objects return immediately even if the job is taking more time to finish. Meanwhile, users can continue to work in the current session without any interruption.
This tutorial will overview the “Start-Job” module in Microsoft.PowerShell.Core.
What is the Start-Job Module in Microsoft.PowerShell.Core?
The cmdlet “Start-Job” is responsible for starting a job in PowerShell. Check out the provided examples for practical demonstration.
Example 1: Use the “Start-Job” Cmdlet to Start a Background Job on a Local Computer
To start the background job on a local computer, first, write the “Start-Job” cmdlet and the “-ScriptBlock” parameter with the certain condition assigned to it:
Example 2: Using the “Start-Job” Module to Run a Script as a Background Job
To execute a script as a background job, first, write the “Start-Job” cmdlet along with the “-FilePath” parameter and specify the path of the script:
Example 3: Get a Process by Using a “Start-Job” Module/Cmdlet
Run the below-stated command to retrieve the process in PowerShell:
According to the above-stated code:
- First, mention the “Start-Job” cmdlet.
- Then, write the “-Name” parameter and assign it the “PShellJob” cmdlet.
- Next, specify the “-ScriptBlock” parameter and provide the stated condition:
Example 4: Specify an Array by Using the ArgumentList Parameter
Execute the given command to specify an array with the aid of an argument list:
In the above-given code:
- First, add the “Start-Job” cmdlet along with the “-ScriptBlock” parameter and assign the stated condition that is specified in the parentheses.
- Next, write the “-ArgumentList” parameter and define the stated values:
That’s it! We have provided a detailed guide about the “Start-Job” module of PowerShell.
Conclusion
The “Start-Job” in “Microsoft.PowerShell.Core” is a module that initiates or starts a job in the background on a local computer. It can get information about the job but does not get its results. The demonstrated post explained the “Start-Job” module in the most comprehensive detail.