I'm trying to clean up a emcopy that went wrong. I've compared the source and destination directories and identified what needs to be removed from a shared drive. I have a couple folders and subfolders that need to be addressed first. I've created the below script however it doesn't seem be able to move the files successfully (moves some files but some files contain commas and other characters and those files seem to be skipped as well as some subfolder files). Also the final destination directory is where the files should be moved to in the case that something was moved incorrectly. Thank you in advance for all your help and as you can see i'm new to powershell and coding.
$Destination = "\\SAN\Share\Backup"
import-csv "D:\Folder.csv" -Header Folder | ForEach-Object {
$FinalDestination = Join-Path $Destination -ChildPath $_.Folder
New-Item -ItemType Directory -path $FinalDestination -Force
}
import-csv "D:\File.csv" -Header File |
ForEach-Object {
Move-Item -LiteralPath $_.File -destination $FinalDestination -Force
}