From 082407d62156a2dd4a797b75b06bd339210e3414 Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Sat, 11 May 2019 13:36:40 -0500 Subject: [PATCH 1/2] Clarify which automatic variable is populated with input for the Microsoft.PowerShell.Core\Start-Job -ScriptBlock parameter description --- reference/4.0/Microsoft.PowerShell.Core/Start-Job.md | 1 + reference/5.0/Microsoft.PowerShell.Core/Start-Job.md | 1 + reference/5.1/Microsoft.PowerShell.Core/Start-Job.md | 1 + reference/6/Microsoft.PowerShell.Core/Start-Job.md | 1 + 4 files changed, 4 insertions(+) diff --git a/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md b/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md index ddb205f001e7..6b089b50312e 100644 --- a/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md @@ -409,6 +409,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..2d8ea2e46b9f 100644 --- a/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md @@ -438,6 +438,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..00b2150915e3 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md @@ -419,6 +419,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..0a8ce3897c76 100644 --- a/reference/6/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/6/Microsoft.PowerShell.Core/Start-Job.md @@ -455,6 +455,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 From 4b8418319ef67c2072bc6e9adc5440b58e2af750 Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Sat, 11 May 2019 13:38:27 -0500 Subject: [PATCH 2/2] Add example showing how to pass and access input in script block for the Microsoft.PowerShell.Core\Start-Job command --- reference/4.0/Microsoft.PowerShell.Core/Start-Job.md | 11 +++++++++++ reference/5.0/Microsoft.PowerShell.Core/Start-Job.md | 11 +++++++++++ reference/5.1/Microsoft.PowerShell.Core/Start-Job.md | 11 +++++++++++ reference/6/Microsoft.PowerShell.Core/Start-Job.md | 11 +++++++++++ 4 files changed, 44 insertions(+) diff --git a/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md b/reference/4.0/Microsoft.PowerShell.Core/Start-Job.md index 6b089b50312e..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 diff --git a/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md b/reference/5.0/Microsoft.PowerShell.Core/Start-Job.md index 2d8ea2e46b9f..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 diff --git a/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md b/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md index 00b2150915e3..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 diff --git a/reference/6/Microsoft.PowerShell.Core/Start-Job.md b/reference/6/Microsoft.PowerShell.Core/Start-Job.md index 0a8ce3897c76..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