草庐IT

notcontains

全部标签

.net - 使用 -notcontains 过滤文件

我正在尝试过滤等于.config的文件扩展名并且文件名中不包含vshost,因此我运行此脚本:$files=dirforeach($filein$files){if($file.Name-notcontains'vshost'-and$file.Extension-eq'.config'){Write-Host$file;}}但输出仍然包含名称中带有vshost的文件:foo.exe.configfoo.vshost.exe.configfoo2.vshost.exe.config预期的输出是:foo.exe.config我缺少什么以及如何解决这个问题? 最