Get-ChildItem无法使用长UNC路径 [英] Get-ChildItem not working with long UNC path
问题描述
我尝试在Powershell中将长UNC路径与Get-ChildItem
一起使用
I try to use long UNC paths with Get-ChildItem
in Powershell like
Get-ChildItem -Path "\\?\c:\blabla"
,Powershell表示路径中包含非法字符. Resolve-Path
可以使用相同的路径.如何在gci
中使用"\\?\"语法?
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
?
推荐答案
好消息! PowerShell v6.0.0-beta.3和更高版本现在默认支持UNC路径;它将UNC字符串自动添加到> 260个字符的路径中:
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
修复PowerShell Core,以允许使用超过260个字符的长路径. (#3960)
Fix PowerShell Core to allow the use of long paths that are more than 260 characters. (#3960)
...
在调用Windows本机API确定某个项目是否存在时,请确保该路径以\?\开头,以允许路径> 260个字符.
When calling Windows native API to determine if an item exists, ensure the path is prepended with \?\ to allow for paths > 260 characters.
您只需下载该版本或更高版本(通过 PowerShell 标签)即可.我刚刚下载了Windows的 v6.0.0-beta.9 x64安装到我的Windows 10计算机上并对其进行了测试,创建了一个包含460个字符的路径!
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!
这篇关于Get-ChildItem无法使用长UNC路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!