How can I exclude multiple folders using Get-ChildItem -exclude?

前端 未结 12 1002
星月不相逢
星月不相逢 2020-11-27 16:19

I need to generate a configuration file for our Pro/Engineer CAD system. I need a recursive list of the folders from a particular drive on our server. However I need to EXCL

12条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 16:54

    You can exclude like this, the regex 'or' symbol, assuming a file you want doesn't have the same name as a folder you're excluding.

    $exclude = 'dir1|dir2|dir3'
    ls -r | where { $_.fullname -notmatch $exclude }
    
    ls -r -dir | where fullname -notmatch 'dir1|dir2|dir3'
    

提交回复
热议问题