Move Databases (Perl)
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 Perl 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 script dismounts the selected database and moves it to the
# designated path.
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE;
$strServerName = '<serverName>';
# e.g. "BATMAN"
$strMDBName = '<mdbName>';
$strNewPath = 'c:\\temp\\';
# ------ END CONFIGURATION ---------
$theServer = Win32::OLE->new('CDOEXM.ExchangeServer');
$theMDB = Win32::OLE->new('CDOEXM.MailboxStoreDB');
$theServer->DataSource->Open($strServerName);
# Get the array list of StorageGroups, then coerce it to get the first
# SG name
$theSGArr = $theServer->StorageGroups;
$theFirstSG = theSGArr(0);
$strURL = 'LDAP://' . $theServer->DirectoryServer . '/cn=' . $strMDBName . ',' . $theFirstSG;
$theMDB->DataSource->Open($strURL);
# dismount the database before attempting to move it
if (($theMDB->Status == 0)) {
$theMDB->Dismount();
}
# move the DB to the specified path, then remount it
$theMDB->MoveDataFiles($strNewPath . $strMDBName . '.edb', $strNewPath . $strMDBName . '.stm');
print "Moved data files for $strMDBName to $strNewPath\n";
$theMDB->Mount();
print "Mounted $strMDBName\n";
|
This code has been viewed 594 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|