Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion reference/5.1/Microsoft.PowerShell.Core/Start-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion reference/6/Microsoft.PowerShell.Core/Start-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand Down
5 changes: 4 additions & 1 deletion reference/7/Microsoft.PowerShell.Core/ForEach-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).
Expand Down
9 changes: 5 additions & 4 deletions reference/7/Microsoft.PowerShell.Core/Start-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
5 changes: 3 additions & 2 deletions reference/7/ThreadJob/Start-ThreadJob.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -30,7 +30,8 @@ Start-ThreadJob [-FilePath] <String> [-Name <String>] [-InitializationScript <Sc
## DESCRIPTION

`Start-ThreadJob` creates background jobs similar to the `Start-Job` cmdlet. The main difference is
that the jobs which are created run in separate threads within the local process.
that the jobs which are created run in separate threads within the local process. By default, the
jobs use the current working directory of the caller that started the job.

The cmdlet also supports a **ThrottleLimit** parameter to limit the number of jobs running at one
time. As more jobs are started, they are queued and wait until the current number of jobs drops
Expand Down