diff --git a/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md b/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md index ddb205f001e7..5eada1642bb9 100644 --- a/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md @@ -167,6 +167,17 @@ This command starts a job that collects a large amount of data and saves it in a The command uses the InitializationScript parameter to run a script block that imports a required module. It also uses the RunAs32 parameter to run the job in a 32-bit process even if the computer has a 64-bit operating system. +### Example 7: Pass input to a background job + +``` +PS C:\> Start-Job -ScriptBlock {Write-Output $Input} -InputObject 'Hello, world!' +``` + +This command starts a job that simply accesses and outputs its input. +The command uses the *InputObject* parameter to pass input to the job. +Input to a job is accessed via the $Input automatic variable. +The $_ automatic variable (alias $PSItem) is not populated. + ## PARAMETERS ### -ArgumentList @@ -409,6 +420,7 @@ Accept wildcard characters: False ### -ScriptBlock Specifies the commands to run in the background job. Enclose the commands in braces ( { } ) to create a script block. +Use the $Input automatic variable to access the value of the *InputObject* parameter. This parameter is required. ```yaml diff --git a/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md b/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md index c7a99867d938..1ad0e1d38757 100644 --- a/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md @@ -186,6 +186,17 @@ This command starts a job that collects lots of data, and then saves it in a .ti The command uses the *InitializationScript* parameter to run a script block that imports a required module. It also uses the *RunAs32* parameter to run the job in a 32-bit process even if the computer has a 64-bit operating system. +### Example 7: Pass input to a background job + +``` +PS C:\> Start-Job -ScriptBlock {Write-Output $Input} -InputObject 'Hello, world!' +``` + +This command starts a job that simply accesses and outputs its input. +The command uses the *InputObject* parameter to pass input to the job. +Input to a job is accessed via the $Input automatic variable. +The $_ automatic variable (alias $PSItem) is not populated. + ## PARAMETERS ### -ArgumentList @@ -438,6 +449,7 @@ Accept wildcard characters: False ### -ScriptBlock Specifies the commands to run in the background job. Enclose the commands in braces ( { } ) to create a script block. +Use the $Input automatic variable to access the value of the *InputObject* parameter. This parameter is required. ```yaml diff --git a/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md b/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md index 9693f86719ac..767767ff3578 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md @@ -167,6 +167,17 @@ This command starts a job that collects lots of data, and then saves it in a .ti The command uses the *InitializationScript* parameter to run a script block that imports a required module. It also uses the *RunAs32* parameter to run the job in a 32-bit process even if the computer has a 64-bit operating system. +### Example 7: Pass input to a background job + +``` +PS C:\> Start-Job -ScriptBlock {Write-Output $Input} -InputObject 'Hello, world!' +``` + +This command starts a job that simply accesses and outputs its input. +The command uses the *InputObject* parameter to pass input to the job. +Input to a job is accessed via the $Input automatic variable. +The $_ automatic variable (alias $PSItem) is not populated. + ## PARAMETERS ### -ArgumentList @@ -419,6 +430,7 @@ Accept wildcard characters: False ### -ScriptBlock Specifies the commands to run in the background job. Enclose the commands in braces ( { } ) to create a script block. +Use the $Input automatic variable to access the value of the *InputObject* parameter. This parameter is required. ```yaml diff --git a/reference/6/Microsoft.PowerShell.Core/Start-Job.md b/reference/6/Microsoft.PowerShell.Core/Start-Job.md index f6f7c345c8ce..eb40e43d981a 100644 --- a/reference/6/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/6/Microsoft.PowerShell.Core/Start-Job.md @@ -190,6 +190,17 @@ This command starts a job that collects lots of data, and then saves it in a .ti The command uses the *InitializationScript* parameter to run a script block that imports a required module. It also uses the *RunAs32* parameter to run the job in a 32-bit process even if the computer has a 64-bit operating system. +### Example 7: Pass input to a background job + +``` +PS C:\> Start-Job -ScriptBlock {Write-Output $Input} -InputObject 'Hello, world!' +``` + +This command starts a job that simply accesses and outputs its input. +The command uses the *InputObject* parameter to pass input to the job. +Input to a job is accessed via the $Input automatic variable. +The $_ automatic variable (alias $PSItem) is not populated. + ## PARAMETERS ### -ArgumentList @@ -455,6 +466,7 @@ Accept wildcard characters: False Specifies the commands to run in the background job. Enclose the commands in braces ( { } ) to create a script block. +Use the $Input automatic variable to access the value of the *InputObject* parameter. This parameter is required. ```yaml