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

前端 未结 10 928
旧时难觅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:26

    $sourcePath="I:\MSSQL\Backup\Full"
    $excludedFiles=@("MASTER", "DBA", "MODEL", "MSDB")
    $sourceFiles=(ls $sourcePath -recurse -file) | where-object { $_.directory.name -notin $excludedFiles }
    

    this is what i did, i needed to copy out a bunch of backup files to a separate location on the network for client pickup. we didn't want them to have the above system DB backups.

提交回复
热议问题