Skip to content

Foreach -parallel does not work when running from a PS drive built with my profile #12194

@aspersram

Description

@aspersram
Strange error when attempting a foreach -parallel command while in a PS drive built in my profile. The error goes away when I switch to my C drive. Note that my S drive is in C. Will show definition:

PS [03/24/2020 07:18:32] C:\Users\a_s_p > get-psdrive s | fl

Name : S
Description :
Provider : Microsoft.PowerShell.Core\FileSystem
Root : C:\Users\a_s_p\Documents\3n
CurrentLocation :

Steps to reproduce

PS [03/24/2020 07:12:02] S:\ > 1..5 | foreach-object -parallel {write-host $_}

Expected behavior

PS [03/24/2020 07:12:03] S:\ > c:
PS [03/24/2020 07:14:56] C:\Users\a_s_p > 1..5 | foreach-object -parallel {write-host $_}
1
2
3
4
5

Actual behavior

PS [03/24/2020 07:12:02] S:\ > 1..5 | foreach-object -parallel {write-host $_}
ForEach-Object: An unexpected error has occurred while processing ForEach-Object -Parallel input. This may mean that some of the piped input did not get processed. Error: System.Ma
nagement.Automation.DriveNotFoundException: Cannot find drive. A drive with the name 'S' does not exist.
at System.Management.Automation.SessionStateInternal.GetDrive(String name, Boolean automount)
at System.Management.Automation.SessionStateInternal.AutomountBuiltInDrive(String name)
at System.Management.Automation.SessionStateInternal.GetDrive(String name, Boolean automount)
at System.Management.Automation.SessionStateInternal.SetLocation(String path, CmdletProviderContext context, Boolean literalPath)
at System.Management.Automation.PSTasks.PSTaskBase.Start()
at System.Management.Automation.PSTasks.PSTaskPool.Add(PSTaskBase task)
at Microsoft.PowerShell.Commands.ForEachObjectCommand.b__63_2(Object _).

Environment data

PS [03/24/2020 07:15:19] C:\Users\a_s_p > $psversiontable

Name Value


PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions