Copy Files

Snippet: Recursively Copy Folder (with excludes) in PowerShell (PowerShell) 
Title: Recursively Copy Folder (with excludes) in PowerShell Language: PowerShell
Description: This function recursively copies a folder and all subfolders while allowing you to properly exclude certain items. Views: 431
Author: Dave Donaldson Date Added: 12/1/2009
 
function CopyFolder($source, $destination, $excludes)
{
    $items = get-childitem $source -recurse -exclude $excludes
    foreach ($item in $items)
    {
        $target = join-path $destination $item.FullName.Substring($source.Length)
        if (-not($item.PSIsContainer -and (test-path($target))))
        {
            copy-item -path $item.FullName -destination $target
        }
    }
}
posted @ 2011-03-24 08:18  chunchill  阅读(296)  评论(0编辑  收藏  举报