简体   繁体   English

在PowerShell中使用get-childitem时处理空白文件夹名称

[英]Dealing with blank folder names while using get-childitem in powershell

I built a script, that searches through all directories recursively with Get-ChildItem .我构建了一个脚本,它使用Get-ChildItem递归搜索所有目录。 The problem is, there exist directories with blank names (done with alt+255).问题是,存在名称为空的目录(使用 alt+255 完成)。

When the script encounters such a directory, it still lists the files in this directory, but does not search in its sub-directories.当脚本遇到这样的目录时,它仍会列出该目录中的文件,但不会在其子目录中进行搜索。

I don't think it is possible in powershell.我认为在 powershell 中是不可能的。 but you can skip to cmd and use但你可以跳到 cmd 并使用

cmd -c dir $Location /s
that works!那个有效!

As @Bert Levrau mentioned above you can do a recursive search in CMD.正如上面提到的@Bert Levrau,您可以在 CMD 中进行递归搜索。 Using Get-ChildItem in Powershell with a folder that has an ALT + 255 name will throw it into an infinite recursive loop.在 Powershell 中将Get-ChildItem与具有 ALT + 255 名称的文件夹一起使用将使其陷入无限递归循环。 You can invoke a CMD process from Powershell though using the following example: $result = cmd /c $directoryPath /s您可以使用以下示例从 Powershell 调用 CMD 进程: $result = cmd /c $directoryPath /s

At that point, you can work through the result to find the information that you need.此时,您可以通过结果找到所需的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM