diff --git a/functions/private/Copy-Files.ps1 b/functions/private/Copy-Files.ps1 index 447df38c..4d30e172 100644 --- a/functions/private/Copy-Files.ps1 +++ b/functions/private/Copy-Files.ps1 @@ -18,31 +18,26 @@ function Copy-Files { try { - $files = Get-ChildItem -Path $path -Recurse:$recurse - Write-Host "Copy $($files.Count)(s) from $path to $destination" + $files = Get-ChildItem -Path $path -Recurse:$recurse + Write-Host "Copy $($files.Count)(s) from $path to $destination" - foreach($file in $files) - { + foreach ($file in $files) { $status = "Copy files {0} on {1}: {2}" -f $counter, $files.Count, $file.Name Write-Progress -Activity "Copy Windows files" -Status $status -PercentComplete ($counter++/$files.count*100) $restpath = $file.FullName -Replace $path, '' - if($file.PSIsContainer -eq $true) - { + if ($file.PSIsContainer -eq $true) { Write-Debug "Creating $($destination + $restpath)" New-Item ($destination+$restpath) -Force:$force -Type Directory -ErrorAction SilentlyContinue - } - else - { + } else { Write-Debug "Copy from $($file.FullName) to $($destination+$restpath)" Copy-Item $file.FullName ($destination+$restpath) -ErrorAction SilentlyContinue -Force:$force Set-ItemProperty -Path ($destination+$restpath) -Name IsReadOnly -Value $false } } Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed - } - Catch{ + } catch { Write-Warning "Unable to Copy all the files due to unhandled exception" Write-Warning $psitem.Exception.StackTrace } -} \ No newline at end of file +}