小编pet*_*cis的帖子

如何使用Get-ChildItem -exclude排除多个文件夹?

我需要为我们的Pro/Engineer CAD系统生成配置文件.我需要一个来自我们服务器上特定驱动器的文件夹的递归列表.但是我需要在其中排除任何带有"ARCHIVE"的文件夹,包括各种不同的情况.

我写了以下哪些有效但除了它不排除文件夹!!

$folder = "T:\Drawings\Design\*"
$raw_txt = "T:\Design Projects\Design_Admin\PowerShell\raw.txt"
$search_pro = "T:\Design Projects\Design_Admin\PowerShell\search.pro"
$archive = *archive*,*Archive*,*ARCHIVE*

Get-ChildItem -Path $folder -Exclude $archive -Recurse  | where {$_.Attributes -match 'Directory'}  | ForEach-Object {$_.FullName} > $search_pro   
Run Code Online (Sandbox Code Playgroud)

directory powershell list

41
推荐指数
7
解决办法
11万
查看次数

标签 统计

directory ×1

list ×1

powershell ×1