Dear All,
Currently using the below script to copy the single file but I need to copy folder, subfolder and files also. Can you someone help me with this
and I need to see the progress of the copy
$sourceFiles = Read-Host "Enter The Restored location with file Name"
$rootDestFolder = Read-Host "Enter The User Request Restore Location"
$resuilt =foreach($sourceFile in $sourceFiles){
$filesplit = $sourceFile.split("\")
$splitcount = $filesplit.count
# This example strips the drive letter & first folder ( ex: E:\Subfolder\ ) but appends the rest of the path to the rootDestFolder
$destFile = $rootDestFolder + "\" + $($($sourceFile.split("\")[2..$splitcount]) -join "\")
# Output List of source and dest
Write-Host ""
Write-Host "Source File Location : $sourceFile " -ForegroundColor Green
Write-Host "Destination File Location : $destFile " -ForegroundColor yello
# Create path and file, if they do not already exist
$destPath = Split-Path $destFile
If(!(Test-Path $destPath)) { New-Item $destPath -Type Directory }
If(!(Test-Path $destFile)) { Copy-Item $sourceFile $destFile -recurse }
}