Recipe 6.3. Enumerating the Storage Groups on a ServerProblemYou want a report that shows you what storage groups exist on your server, and where their database and log files are located. SolutionUsing a graphical user interface
Using VBScript' This code lists all of the storage groups, and databases within them, ' on the target server. ' ------ SCRIPT CONFIGURATION ------ strComputerName = "<serverName>" ' e.g., "batman" ' ------ END CONFIGURATION --------- set theServer = CreateObject("CDOEXM.ExchangeServer") Set theSG = CreateObject("CDOEXM.StorageGroup") Set thePF = CreateObject("CDOEXM.PublicStoreDB") Set theMB = CreateObject("CDOEXM.MailboxStoreDB") theServer.DataSource.Open strComputerName ' examine the SGs; for each SG, list its associated stores and paths For Each sg In theServer.StorageGroups WScript.Echo "Storage group " & Chr(34) & sg & Chr(34) theSG.DataSource.open sg i = 0 For Each mailDB In theSG.MailboxStoreDBs i = i+1 WScript.Echo " Mailbox database " & i & ": " & mailDB theMB.DataSource.open mailDB WScript.Echo " Name:" & theMB.name WScript.Echo " Path:" & theMB.DBPath Next i = 0 For Each pubDB In theSG.PublicStoreDBs i = i+1 WScript.Echo " PF database " & i & ": " & pubDB thePF.DataSource.open pubDB WScript.Echo " Name:" & thePF.Name WScript.Echo " Path:" & thePF.DBPath Next Next DiscussionSGs have a variety of properties available through CDOEXM, including the names (both common and distinguished) of databases in the SG and the log and database file paths for the databases. You can view and set these properties by using code like that shown in the solution; however, you won't be able to change the log or database file locations by changing the associated properties. Instead, you'll have to use the MoveLogFiles( ) and MoveSystemFiles() methods (see Recipe 6.9). See AlsoRecipes Recipe 6.1 and Recipe 6.2 for creating and deleting storage groups and Recipe 6.9 for moving databases and log files; MSDN: IStorageGroup class documentation |