Recipe 6.2. Deleting a Storage GroupProblemYou want to delete a storage group on an Exchange server. SolutionUsing a graphical user interface
Using VBScript' This code deletes the selected storage group. ' ------ SCRIPT CONFIGURATION ------ strComputerName = "<serverName>" ' e.g., "batman" strSGName = "<storageGroupName>" ' e.g., "New Storage Group" ' ------ END CONFIGURATION --------- set theServer = CreateObject("CDOEXM.ExchangeServer") Set theSG = CreateObject("CDOEXM.StorageGroup") theServer.DataSource.Open strComputerName ' examine the SGs and see if we can find ours. This code will ' delete any SG whose name contains strSGName, so be careful! For Each sg In theServer.StorageGroups WScript.Echo "Examining " & sg isIn = InStr(1, UCase(sg), UCase(strSGName)) If (isIn<>0) Then wscript.echo "Deleting " & sg theSG.DataSource.Open "LDAP://" & theServer.DirectoryServer & "/" & sg ' delete the storage group theSG.DataSource.Delete WScript.Echo "Deleted SG " & sg End if Next DiscussionUnlike mailbox or public databases, the SG object itself doesn't really have any useful data in it; it's a container that points to a set of transaction logs and databases. Accordingly, when you remove it, the corresponding directory object is removed but nothing changes on the target server's filesystem. You can easily recreate a deleted SG, since the databases and log files are left intact (but orphaned) when you delete the SG itself. You must first delete (or move) any mailbox or public folder stores that are housed in the SG. If you attempt to delete a SG that still contains active databases, ESM will complain; if you're doing it from within a script, the script will fail. See AlsoRecipe 6.1 for creating storage groups, Recipe 5.6 for moving mailboxes, Recipe Recipe 6.6 for deleting databases, and MSDN CDOEXM documentation |