I am very new to PS and I was wondering if someone could help me with a PS scripting problem.
I need to recover data from a server that was using MailMeter Archiver
as a back-up tool (not my idea). When the company upgraded to MSS2008R2
on a newer server they tried to copy the back-up from the old server to the new server.
Although a lot of the data copied over, it left a load of 0KB
files and folder structure. The data is still intact on the old server, but live data has been updated, so I can't just copy the archived data over.
I have scripted a search to find all the 0KB
files in their folder structure,
Get-ChildItem -Path C:\%Folders% -Recurse -Filter *.* | Where {$_.Length -eq 0} | Select-Object FullName | Add-Content -Path C:\Test\%filename%
but I am stuck on how I would script reading of the output file, searching the old server directory, copying the files and overwriting the 0KB
files in the folder structure with the original data... there is ~37000
data items missing... Pointers? Anyone?
Not sure what exactly you want to do. So basically overwrite all 0kb files with the originals from the old structure? Like this?
$oldDir = "C:\server1"
$newDir = "C:\server2"
# get all 0kb files
Get-ChildItem $newDir -Recurse -Filter *.* | where { $_.Length -eq 0 } | foreach {
# get original path and copy/overwrite
Copy-Item $_.FullName.Replace($newDir, $oldDir) $_.FullName -Force -Confirm:$false
}
Let me know if this is what you need.