问题
接收PathTooLongException - ..。完全限定的文件名必须小于260个字符,目录名必须小于248个字符。
OS
PowerShell版本
5.1.14409.1018
.NET FrameWork版本
码
Get-ChildItem -Path $path -Directory -Recurse | Get-ACL
ForEach ($item in $pathmany) {
$permissions = $item.access | where {$_.IdentityReference -like "*$target*"}
$permissions.FullPath | where {$_.IdentityReference -like "*$target*"}
if ($permissions.IdentityReference -like "*$target*") {
$path = $item.Path.trim('Microsoft.PowerShell.Core\FileSystem::')
}
}到目前为止我尝试过的
1-设置位置“进一步进入文件夹树”(错误)
2- Subst TEMP“文件夹进一步进入文件夹树”(错误)
3-\计算机名\“文件夹进一步进入文件夹树”\(错误)
4-使用2019年服务器,可以将注册表编辑为"LongPathsEnabled = 1“,我还尝试使用\\UNC\方法,它返回相同的错误。
也尝试了这段代码,但仍然得到了错误。
$folder = @{ Name = "\\?\UNC"}
$folder.path = "folder further into folder tree"
$folder | ForEach-Object {
$item = Get-ChildItem -Path $_.Path -Directory -Recurse | Get-ACL
}询问我的主管是否可以升级到PowerShell 6.0或7.0。
任何帮助或想法都将不胜感激。
发布于 2020-04-08 13:00:02
我在PowerShell 7中使用了上面的脚本,代码能够检索我获取LongPathException错误的文件夹。然而,我得到了一个新的错误,我将发布另一个问题。我能够想出并解决我的问题的答案如下。我能够计数文件夹树L:\ 145,000+中的文件夹。
脚本问题错误
Get-ChildItem -Path "L:\Depts" -Directory -Recurse安装PowerShell 7.0将纠正错误
Get-ChildItem : The specified path, file name, or both are too long. The fully
qualified file name must be less than 260 characters, and the directory name must
be less than 248 characters.https://stackoverflow.com/questions/60994380
复制相似问题