diff --git a/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md b/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md index 312416baed59..25a39b619541 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Start-Job.md @@ -3,7 +3,7 @@ external help file: System.Management.Automation.dll-Help.xml keywords: powershell,cmdlet locale: en-us Module Name: Microsoft.PowerShell.Core -ms.date: 08/09/2019 +ms.date: 11/04/2019 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/start-job?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Start-Job @@ -67,6 +67,10 @@ Starting in PowerShell 3.0, `Start-Job` can start instances of custom job types, jobs. For information about how to use `Start-Job` to start jobs with custom types, see the help documents for the job type feature. +The default working directory for jobs is hardcoded. The Windows default is `$HOME\Documents` and on +Linux or macOS the default is `$HOME`. The script code running in the background job needs to manage +the working directory as needed. + ## EXAMPLES ### Example 1: Start a background job diff --git a/reference/6/Microsoft.PowerShell.Core/Start-Job.md b/reference/6/Microsoft.PowerShell.Core/Start-Job.md index 815c1c3a9e3e..eaa4cfdd4536 100644 --- a/reference/6/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/6/Microsoft.PowerShell.Core/Start-Job.md @@ -3,7 +3,7 @@ external help file: System.Management.Automation.dll-Help.xml keywords: powershell,cmdlet locale: en-us Module Name: Microsoft.PowerShell.Core -ms.date: 10/23/2019 +ms.date: 11/04/2019 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/start-job?view=powershell-6&WT.mc_id=ps-gethelp schema: 2.0.0 title: Start-Job @@ -72,6 +72,10 @@ functionality of the background operator is similar to `Start-Job`. Both methods create a **PSRemotingJob** job object. For more information about using the ampersand (`&`), see [about_Operators](./about/about_operators.md#background-operator-). +The default working directory for jobs is hardcoded. The Windows default is `$HOME\Documents` and on +Linux or macOS the default is `$HOME`. The script code running in the background job needs to manage +the working directory as needed. + > [!NOTE] > Creating an out-of-process background job with `Start-Job` is not supported in the scenario where > PowerShell is being hosted in other applications, such as the PowerShell Azure Functions. diff --git a/reference/7/Microsoft.PowerShell.Core/About/about_Operators.md b/reference/7/Microsoft.PowerShell.Core/About/about_Operators.md index da00a63d3fbe..a5826b8b8bd8 100644 --- a/reference/7/Microsoft.PowerShell.Core/About/about_Operators.md +++ b/reference/7/Microsoft.PowerShell.Core/About/about_Operators.md @@ -201,8 +201,9 @@ Runs the pipeline before it in the background, in a PowerShell job. This operator acts similarly to the UNIX control operator ampersand (`&`), which runs the command before it asynchronously in sub shell as a job. -This operator is functionally equivalent to `Start-Job`. The following example -demonstrates basic usage of the background job operator. +This operator is functionally equivalent to `Start-Job`. By default, the background operator starts +the jobs in the current working directory of the caller that started the parallel tasks. The +following example demonstrates basic usage of the background job operator. ```powershell Get-Process -Name pwsh & diff --git a/reference/7/Microsoft.PowerShell.Core/ForEach-Object.md b/reference/7/Microsoft.PowerShell.Core/ForEach-Object.md index bf56ada51f89..948ab9a71d5c 100644 --- a/reference/7/Microsoft.PowerShell.Core/ForEach-Object.md +++ b/reference/7/Microsoft.PowerShell.Core/ForEach-Object.md @@ -3,7 +3,7 @@ external help file: System.Management.Automation.dll-Help.xml keywords: powershell,cmdlet locale: en-us Module Name: Microsoft.PowerShell.Core -ms.date: 09/16/2019 +ms.date: 11/04/2019 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 title: ForEach-Object @@ -73,6 +73,9 @@ Starting in Windows PowerShell 3.0, there are two different ways to construct a represent the current input object in the script block. Use the `$using:` keyword to pass variable references to the running script. + By default, the parallel scriptblocks use the current working directory of the caller that started + the parallel tasks. + > [!NOTE] > This is an experimental feature. For more information see > [about_Experimental_Features](about/about_Experimental_Features.md). diff --git a/reference/7/Microsoft.PowerShell.Core/Start-Job.md b/reference/7/Microsoft.PowerShell.Core/Start-Job.md index c0d4da277254..5fa63174463c 100644 --- a/reference/7/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/7/Microsoft.PowerShell.Core/Start-Job.md @@ -3,7 +3,7 @@ external help file: System.Management.Automation.dll-Help.xml keywords: powershell,cmdlet locale: en-us Module Name: Microsoft.PowerShell.Core -ms.date: 10/23/2019 +ms.date: 11/04/2019 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/start-job?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 title: Start-Job @@ -76,7 +76,8 @@ create a **PSRemotingJob** job object. For more information about using the ampe [about_Operators](./about/about_operators.md#background-operator-). PowerShell 7 introduced the **WorkingDirectory** parameter that specifies a background job's initial -working directory. +working directory. If the parameter isn't specified, `Start-Job` defaults to the current working +directory of the caller that started the job. > [!NOTE] > Creating an out-of-process background job with `Start-Job` is not supported in the scenario where @@ -600,8 +601,8 @@ Accept wildcard characters: False ### -WorkingDirectory Specifies the initial working directory of the background job. If the parameter isn't specified, the -job runs from the default location. The Windows default is `$HOME\Documents` and on Linux or macOS -the default is `$HOME`. +job runs from the default location. The default location is the current working directory of the +caller that started the job. This parameter was introduced in PowerShell 7. diff --git a/reference/7/ThreadJob/Start-ThreadJob.md b/reference/7/ThreadJob/Start-ThreadJob.md index 31b73ef8f4d9..9f9fa25df56d 100644 --- a/reference/7/ThreadJob/Start-ThreadJob.md +++ b/reference/7/ThreadJob/Start-ThreadJob.md @@ -1,7 +1,7 @@ --- external help file: ThreadJob.dll-Help.xml Module Name: threadjob -ms.date: 07/09/2019 +ms.date: 11/04/2019 online version: https://docs.microsoft.com/powershell/module/threadjob/start-threadjob?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 title: Start-ThreadJob @@ -30,7 +30,8 @@ Start-ThreadJob [-FilePath] [-Name ] [-InitializationScript