728x90

Function Copy-WithProgress
{
    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory=$true,
            ValueFromPipelineByPropertyName=$true,
            Position=0)]
        $Source,
        [Parameter(Mandatory=$true,
            ValueFromPipelineByPropertyName=$true,
            Position=0)]
        $Destination
    )

    $Source=$Source.tolower()
#    $Filelist=Get-Childitem "$Source" –Recurse   -- 대상 폴더안의 파일 및 폴더 전체를 리스트함.
    $Filelist=Get-Childitem 파일명
    $Total=$Filelist.count
    $Position=0


    foreach ($File in $Filelist)
    {
        $Filename=$File.Fullname.tolower().replace($Source,'')
        #$Filename= 파일명
        $DestinationFile=($Destination+$Filename)
        Write-Progress -Activity "Copying data from '$source' to '$Destination'" -Status "Copying File $Filename" -PercentComplete (($Position/$total)*100)
        Copy-Item $File.FullName -Destination $DestinationFile
        $Position++
    }
}

$src="c:\temp"
$dest="C:\Temp\download"

Copy-WithProgress -Source $src -Destination $dest

#복사 완료 후 제거 
Remove-Item c:\temp\sw_dvd5_office_professional_plus_2016_64bit_korean_mlf.iso -Force  

728x90

+ Recent posts