I try to use long UNC paths with Get-ChildItem
in Powershell like
Get-ChildItem -Path "\\?\c:\blabla"
and Powershell says that there are illegal characters in the path. The very same path works with Resolve-Path
. How can I use the "\\?\" syntax with gci
?
Great news! PowerShell v6.0.0-beta.3 and up now supports UNC paths by default; it automatically prepends the UNC string to paths > 260 characters:
https://github.com/PowerShell/PowerShell/releases/tag/v6.0.0-beta.3 https://github.com/PowerShell/PowerShell/pull/3960 https://github.com/PowerShell/PowerShell/pull/3960/files/3e7e28d49f306ab4874e32cf10eabb43559dae26#diff-52b1a915619c71b288b3f92f944924c4
Fix PowerShell Core to allow the use of long paths that are more than 260 characters. (#3960)
...
When calling Windows native API to determine if an item exists, ensure the path is prepended with \?\ to allow for paths > 260 characters.
You simply have to download that version or later (via. the PowerShell tags). I just downloaded v6.0.0-beta.9 for Windows x64 onto my Windows 10 machine and tested it out, creating a path with some 460 characters!