RestorePreexisting.VBS
Published Apr 10 2019 01:22 AM 263 Views
Iron Contributor
First published on TECHNET on May 02, 2007


02 / JAN, 2008 NOTE: NEW VERSION OF THIS SCRIPT AVAILABLE HERE

--------



'==========================================================================
'
'
' NAME: RestorePreexisting.VBS
'
'  AUTHOR: Ned Pyle, EPS, Microsoft Corporation
'
'
'  COMMENT: Disaster Recovery script for pulling DFSR data out of Preexisting
'           and putting it back into a usable directory tree, preserving paths
'           names, and security descriptor info.
'
'  USAGE: Replace the 3 variables in the "operator edited" section below
'         with valid paths. The Script will copy the contents of the preexisting
'         to a specified path, returning files/folders to original names and adding back
'         their folder structure at the time of deletion.
'
'         It is important to note that duplicate conflicts will not copy - check
'         the restoreconflicted.log to see which files need manual intervention
'         (this is done to prevent the accidental restore of an older conflicted copy)
'
'
'  VERSION HISTORY:
'
'
'   1.01 / 04/18/07
'    Adds OR support for folder attribute types of 10 or 30
'
'   1.00 / 04/18/07 -
'   First working version
'
'
' This script is provided "AS IS" with no warranties, and confers no rights.
' For more information please visit
' http://www.microsoft.com/info/cpyright.mspx to find terms of use.
'
'==========================================================================


Dim Source
Dim Dest
Const quote = """"

' Startup XML
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False

' Set File Move Environment
Set objShell = WScript.CreateObject("WScript.Shell")





'=======================================================================
' Section must be operator-edited to provide valid paths
'=======================================================================

' Change path to specify location of C&D Manifest
objXMLDoc.load("C:replicatedfolderDfsrPrivatepreexistingManifest.xml")

' Change path to specify location of conflicted files
PreexistingFolder = ("C:replicatedfolderDfsrPrivatepreexisting")

' Change path to specify output folder - must be on a disk that has as much free space as the preexisting folder is taking up
OutputFolder = ("c:dfsr_repair_tree")

'========================================================================





set objRootNodes = objXMLDoc.documentElement.ChildNodes

For Each objRootNode In objRootNodes

Set objChildNodes = objRootNode.ChildNodes
For Each objChildNode in objChildNodes

If objChildNode.nodeName = "Path" then
StrFullPath = objChildNode.firstChild.nodeValue
end if

If objChildNode.nodeName = "Attributes" then
FileorFolder = objChildNode.firstChild.nodeValue
end if


If objChildNode.nodeName = "NewName" then

GuidName = objChildNode.firstChild.nodeValue

If GuidName <> "" then

Length = Len(StrFullPath)
StrExtract = Mid(strFullPath, 7, Length-6)

Source = PreexistingFolder & GuidName
Dest = OutputFolder & strExtract

' check if not a folder

if FileorFolder <> 10 or 30 then

wscript.echo "CMD /C XCOPY " & quote & Source & quote & " " & quote & Dest & quote & " " & "/Q /H /R /O /C"
objShell.Run "CMD /C ECHO F | XCOPY " & quote & Source & quote & " " & quote & Dest & quote & " " & "/Q /H /R /O /F",0,TRUE

else

wscript.echo "CMD /C XCOPY " & quote & Source & quote & " " & quote & Dest & quote & " " & "/Q /H /R /O /Y /E /I /C"
objShell.Run "CMD /C ECHO F | XCOPY " & quote & Source & quote & " " & quote & Dest & quote & " " & "/Q /H /R /O /Y /E /I /C /F",0,TRUE

end if

end if

end if

Next

Next

Version history
Last update:
‎Apr 10 2019 01:22 AM
Updated by: