Mar 14 2010

Disaster recovery: Metadata cleanup

When you perform a complete domain or forest recovery, after you have restored the first DC system state, you have to cleanup metadata of the DCs on which you will reinstall AD using a DCPromo. For more information about disaster recovery plans I suggest you read this document.

On a Windows 2008 server when you delete the DC computer object, server object removal (cn=ServerName,cn=Servers,cn=SiteName, cn=Sites,cn=Configuration,dc=ForestRootDomain) and metadata cleanup are performed automatically. On a Windows 2003 server you need to use the ntdsutil command line tool and delete the server object manually. This post describes how to set up a semi automated process to perform these steps.

If your IT infrastructure is composed of many DCs, metadata cleanup is time consuming and when disaster strikes, what you need is to get your domain up and running as quickly as possible. The script below performs server object deletion and metadata cleanup . All you need is a text file named list.txt with the DN of your Domain Controllers servers objects on which you need to perform the operation on each line. Prepare this list in advance and don’t forget to update it when you install or remove a DC.

1
2
3
4
5
6
7
8
9
10
11
12
13
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
sCurPath = fso.GetAbsolutePathName(".")
Set f2 = fso.OpenTextFile(sCurPath&"\list.txt",ForReading)
Set shl = Wscript.CreateObject("Wscript.Shell")
Do While f2.AtEndOfStream <> True
    DC = f2.ReadLine
    shl.run "cmd /c ntdsutil "&chr(34)&"popups off"&chr(34)&" "&chr(34)&"metadata cleanup"&chr(34)&" "&chr(34)&"remove selected server "&DC&chr(34)&" quit quit >> "&chr(34)&sCurPath&"\result.txt"&chr(34),2,True
    set objComputer = GetObject("LDAP://"&DC)
    objComputer.DeleteObject (0) 
    MsgBox DC&" Medata cleanup completed and server object deleted"
Loop
f2.close

Just click on the picture below to download the script:

Metadata cleanup result is returned in the result.txt file. This script was validated on a test platform, I hope you will never have to use it in a production environment.

This post is also available in: French

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

*

WordPress Themes

Blossom Icon Set

Software Top Blogs