Prerequisites
Steps to reproduce
I am trying to script to recursively search file systems, and 7.2 preview 9 aborts the Get-ChildItem command with file paths>MAX_PATH (260) chars. This issue does not happen with prior versions.
Example folder seen in Win 10 that will cause this:
"C:\ProgramData\Microsoft\Windows\Containers\BaseImages\61be50b1-e59b-45c7-9460-020d3f6bc848\BaseLayer\Files\Program Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1\Diagnostics\Simple"
- Found initially when searching for files using: gci -Path C:\ -Recurse -Force -ErrorAction SilentlyContinue
- The "Simple" child folder exceeds MAX_PATH (260) chars and is where it bombs out
- It seems to ignore -ErrorAction SilentlyContinue
To rule out permission issues, I created a separate test folder structure on my D: drive with the same length and had the same results with it:
B:\Batch>mkdir "\\?\D:\DrogramTest\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1\Diagnostics\Simple"
B:\Batch>dir "\\?\D:\DrogramTest\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1\Diagnostics\Simple"
Volume in drive \\?\D: is Toshiba5TB
Volume Serial Number is 625A-B5E5
Directory of \\?\D:\DrogramTest\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1\Diagnostics\Simple
2021.09.19 18:23 <DIR> .
2021.09.19 18:23 <DIR> ..
0 File(s) 0 bytes
Simply then attempting gci D:\DrogramTest -Recurse -Force will result in it aborting with the error.
Expected behavior
Behavior With 7.2.0 Preview 8 (and prior versions)
PowerShell 7.2.0-preview.8
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS B:\PSH\PowerShell-7.2.0-preview.8-win-x64> Get-ChildItem -Path "C:\ProgramData\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1\" -Recurse -ErrorAction SilentlyContinue -Force
Directory:
C:\ProgramData\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program
Files
(x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2021.05.22 09:54 Diagnostics
Directory:
C:\ProgramData\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program
Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics
\1.0.1\Diagnostics
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2021.05.22 09:54 Simple
PS B:\PSH\PowerShell-7.2.0-preview.8-win-x64>
Actual behavior
Behavior With 7.2.0 Preview 9
PowerShell 7.2.0-preview.9
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS B:\PSH\PowerShell-7.2.0-preview.9-win-x64> Get-ChildItem -Path "C:\ProgramData\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1\" -Recurse -ErrorAction SilentlyContinue -Force
Directory:
C:\ProgramData\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program
Files
(x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2021.05.22 09:54 Diagnostics
Directory:
C:\ProgramData\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program
Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics
\1.0.1\Diagnostics
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2021.05.22 09:54
Get-ChildItem: The system cannot find the path specified.
PS B:\PSH\PowerShell-7.2.0-preview.9-win-x64>
Error details
PS B:\> Get-Error
Exception :
Type : System.ComponentModel.Win32Exception
NativeErrorCode : 3
ErrorCode : -2147467259
TargetSite :
Name : IsReparsePointLikeSymlink
DeclaringType : Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods
MemberType : Method
Module : System.Management.Automation.dll
Message : The system cannot find the path specified.
Source : System.Management.Automation
HResult : -2147467259
StackTrace :
at Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods.IsReparsePointLikeSymlink(FileSystemInfo
fileInfo) in System.Management.Automation.dll:token 0x60016fa+0x6d
at Microsoft.PowerShell.Commands.FileSystemProvider.Dir(DirectoryInfo directory, Boolean recurse, UInt32 depth,
Boolean nameOnly, ReturnContainers returnContainers, InodeTracker tracker) in System.Management.Automation.dll:token
0x6001657+0x31b
at Microsoft.PowerShell.Commands.FileSystemProvider.Dir(DirectoryInfo directory, Boolean recurse, UInt32 depth,
Boolean nameOnly, ReturnContainers returnContainers, InodeTracker tracker) in System.Management.Automation.dll:token
0x6001657+0x34f
at Microsoft.PowerShell.Commands.FileSystemProvider.GetPathItems(String path, Boolean recurse, UInt32 depth,
Boolean nameOnly, ReturnContainers returnContainers) in System.Management.Automation.dll:token 0x6001656+0x5a
at Microsoft.PowerShell.Commands.FileSystemProvider.GetChildItems(String path, Boolean recurse, UInt32 depth) in
System.Management.Automation.dll:token 0x6001653+0x0
at System.Management.Automation.SessionStateInternal.GetChildItems(CmdletProvider providerInstance, String path,
Boolean recurse, UInt32 depth, CmdletProviderContext context) in System.Management.Automation.dll:token 0x6003a8e+0x7
CategoryInfo : NotSpecified: (:) [Get-ChildItem], Win32Exception
FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.GetChildItemCommand
InvocationInfo :
MyCommand : Get-ChildItem
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 1
Line : Get-ChildItem -Path
"C:\ProgramData\Microsoft\Windows\Containers\BaseImages\283a08b6-ccbf-4c2d-a79e-cab35a294e78\BaseLayer\Files\Program
Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics
\1.0.1\" -Recurse -ErrorAction SilentlyContinue -Force
PositionMessage : At line:1 char:1
+ Get-ChildItem -Path "C:\ProgramData\Microsoft\Windows\Containers\Base …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Get-ChildItem
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
Name Value
---- -----
PSVersion 7.2.0-preview.9
PSEdition Core
GitCommitId 7.2.0-preview.9
OS Microsoft Windows 10.0.21390
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
I am trying to script to recursively search file systems, and 7.2 preview 9 aborts the Get-ChildItem command with file paths>MAX_PATH (260) chars. This issue does not happen with prior versions.
Example folder seen in Win 10 that will cause this:
"C:\ProgramData\Microsoft\Windows\Containers\BaseImages\61be50b1-e59b-45c7-9460-020d3f6bc848\BaseLayer\Files\Program Files (x86)\WindowsPowerShell\Modules\Microsoft.PowerShell.Operation.Validation\1.0.1\Test\Modules\Example2.Diagnostics\1.0.1\Diagnostics\Simple"To rule out permission issues, I created a separate test folder structure on my D: drive with the same length and had the same results with it:
Simply then attempting gci D:\DrogramTest -Recurse -Force will result in it aborting with the error.
Expected behavior
Actual behavior
Error details
Environment data
Visuals
No response