【发布时间】:2014-10-14 15:07:30
【问题描述】:
我正在创建一个小脚本,它将列出计算机上的 EXE 文件。
$computername = get-content env:computername
get-childitem C: -recurse | ? {$_.fullname -notmatch 'C:\\Windows'} | where {$_.extension -eq ".exe"} | format-table fullname | Out-File "\\server\incomming\$computername.txt"
问题在于 -notmatch 不接受更多语句。我可以复制粘贴? {$_.fullname -notmatch 'C:\\Windows'} 并用于其他文件夹,如 Program Files (x86)、Program Files 等。但我不想让脚本过于臃肿。
有没有办法可以用 -notmatch 语句排除大量文件夹?
【问题讨论】: