Exclude list in PowerShell Copy-Item does not appear to be working

前端 未结 10 911
旧时难觅i
旧时难觅i 2020-12-02 11:40

I have the following snippet of PowerShell script:

$source = \'d:\\t1\\*\'
$dest = \'d:\\t2\'
$exclude = @(\'*.pdb\',\'*.config\')
Copy-Item $source $dest -R         


        
10条回答
  •  爱一瞬间的悲伤
    2020-12-02 12:43

    I had this problem, too, and spent 20 minutes with applying the solutions here, but kept having problems.
    So I chose to use robocopy - OK, it's not powershell, but should be available everywhere where powershell runs.

    And it worked right out of the box:

    robocopy $source $dest /S /XF  /XD 
    

    e.g.

    robocopy $source $dest /S /XF *.csproj /XD obj Properties Controllers Models
    

    Plus, it has tons of features, like resumable copy. Docs here.

提交回复
热议问题