Skip to content

Starting background job in a UNC path with & returns error #18618

@johanringman

Description

@johanringman

Prerequisites

Steps to reproduce

Since Powershell 7.3 i can't start a background job via the & shorthand with an UNC path as working directory.
It's working fine when using Start-Job { }.

Expected behavior

PS Microsoft.PowerShell.Core\FileSystem::\\localhost\Share> $null &

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
1      Job1            BackgroundJob   Running       True            localhost            Microsoft.PowerShell.Man…

Actual behavior

PS Microsoft.PowerShell.Core\FileSystem::\\localhost\Share> $null &
Start-Job: Cannot find the WorkingDirectory path Microsoft.PowerShell.Core\FileSystem::\\localhost\Share.

Error details

Exception             :
    Type       : System.IO.DirectoryNotFoundException
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.3.0.500, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message    : Cannot find the WorkingDirectory path Microsoft.PowerShell.Core\FileSystem::\\localhost\Share.
    Source     : System.Management.Automation
    HResult    : -2147024893
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
CategoryInfo          : InvalidOperation: (:) [Start-Job], DirectoryNotFoundException
FullyQualifiedErrorId : DirectoryNotFoundException,Microsoft.PowerShell.Commands.StartJobCommand
InvocationInfo        :
    MyCommand        : Start-Job
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : -1
    Line             : $null &
    PositionMessage  : At line:1 char:1
                       + $null &
                       + ~~~~~
    InvocationName   : Start-Job
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Powershell 7 3

Powershell 7 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions