You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, the overridden method ItemExists in FileSystemProvider does not properly handle paths with lengths in excess of MAX_PATH (260) characters. This adversely affects several cmdlets, including Test-Path, Set-Location, and Remove-Item, as well as TAB expansion.
Steps to reproduce
PS C:\Temp\longish-directory-name>$longname='a'*250
PS C:\Temp\longish-directory-name>New-Item-ItemType Directory $longname
Directory: C:\temp\longish-directory-name
Mode LastWriteTime Length Name
---------------------------
d-----5/30/20178:59 PM aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaa
PS C:\Temp\longish-directory-name>Test-Path$longname
False
PS C:\Temp\longish-directory-name>Set-Location aa<TAB>
PS C:\Temp\longish-directory-name>Set-Location$longnameSet-Location : Cannot find path 'C:\temp\longish-directory-name\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
because it does not exist.
At line:1 char:1+Set-Location$longname+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\temp\longish...aaaaaaaaaaaaa
aa:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLo
cationCommand
PS C:\Temp\longish-directory-name>Remove-Item$longnameRemove-Item : Cannot find path 'C:\temp\longish-directory-name\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
because it does not exist.
At line:1 char:1+Remove-Item$longname+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\temp\longish...aaaaaaaaaaaaa
aa:String) [Remove-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.Remov
eItemCommand
Expected behavior
The long-named sub-directory was successfully created, so
Test-Path $longname should return True
Set-Location aa<TAB> should expand to the long directory name
Set-Location $longname should change to the long-named sub-directory
After returning to the parent directory, Remove-Item $longname should delete the directory
All of these work correctly on Unix environments.
Actual behavior
Test-Path $longname returns False
Set-Location aa<TAB> does nothing
Set-Location $longname fails with cannot-find-path error
Remove-Item $longname fails with cannot-find-path error
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.0.0-beta
PSEdition Core
BuildVersion 3.0.0.0
CLRVersion
GitCommitId v6.0.0-beta.1-32-g5cc46d9bcd9627f4a62b3c4825d...
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
On Windows, the overridden method
ItemExistsinFileSystemProviderdoes not properly handle paths with lengths in excess ofMAX_PATH(260) characters. This adversely affects several cmdlets, includingTest-Path,Set-Location, andRemove-Item, as well as TAB expansion.Steps to reproduce
Expected behavior
The long-named sub-directory was successfully created, so
Test-Path $longnameshould return TrueSet-Location aa<TAB>should expand to the long directory nameSet-Location $longnameshould change to the long-named sub-directoryRemove-Item $longnameshould delete the directoryAll of these work correctly on Unix environments.
Actual behavior
Test-Path $longnamereturns FalseSet-Location aa<TAB>does nothingSet-Location $longnamefails with cannot-find-path errorRemove-Item $longnamefails with cannot-find-path errorEnvironment data