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

前端 未结 12 936
星月不相逢
星月不相逢 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:52

    Based on @NN_ comment on @Guillem answer, I came up with the below code. This allows you to exclude folders and files:

    Get-ChildItem -Exclude 'folder-to-exclude','second-folder-exclude' |
    foreach {
        Get-ChildItem -Path $_ -Exclude 'files-to-exclude','*.zip','*.mdmp','*.out*','*.log' -Recurse |
        Select-String -Pattern 'string-to-look-for' -List
    }
    

提交回复
热议问题