Delete Database (VBScript)
This code can be found in
Chapter 6 of Exchange Server Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' This script was originally published in the Exchange Cookbook,
' (http://www.exchangebookcook.com). Written by Paul Robichaux,
' Missy Koslosky, and Devin Ganger. Redistributed with permission
' of the publisher, O'Reilly & Associates.
' This code removes the specified database from its
' parent storage group without touching the on-disk files
' ------ SCRIPT CONFIGURATION ------
strServerName = "<serverName>" ' e.g. "BATMAN"
strMDBName = "<mdbName>"
' ------ END CONFIGURATION ---------
Set theServer = CreateObject("CDOEXM.ExchangeServer")
Set theMDB = CreateObject("CDOEXM.MailboxStoreDB")
' bind to the Exchange server and build the database URL
theServer.DataSource.Open strServerName
' Get the array list of StorageGroups, then coerce it to get the first
' SG name. You'd need to modify this to delete a database in a
' storage group other than the first one.
theSGArr = theServer.StorageGroups
theFirstSG = theSGArr(0)
strURL = "LDAP://" & theServer.DirectoryServer & "/cn=" & strMDBName & "," & theFirstSG
theMDB.Name = strMDBName
theMDB.DataSource.Open strURL
theMDB.DataSource.Delete
WScript.Echo "Deleted MDB " & strMDBName
|
This code has been viewed 1037 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|