Note: the line to actually delete a store is commented out below. Please think carefully before uncommenting.

Source Code

This script has not been checked by Spiceworks. Please understand the risks before using it.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

quot=chr(34)SetiServer=CreateObject("CDOEXM.ExchangeServer")SetiMDB=CreateObject("CDOEXM.MailboxStoreDB")' check command lineGetArgsstrMode,strComputerName,strSGName,strMDBName,CorrectSyntaxIfCorrectSyntaxThenBindMailboxStorestrComputerName,strSGName,strMDBNameSelectCasestrModeCase"mount"wscript.echo"Mounting Database "&strMDBName&" in Storage Group "&strSGName&" on "&strComputerNameiMDB.mountCase"dismount"wscript.echo"Dismounting Database "&strMDBName&" in Storage Group "&strSGName&" on "&strComputerNameiMDB.dismountCase"delete"wscript.echo"Deleting Database "&strMDBName&" in Storage Group "&strSGName&" on "&strComputerName'iMDB.DataSource.deleteEndSelect' CleanupSetiServer=NothingSetiMDB=NothingElseDisplayHelpwscript.quitEndIfSubBindMailboxStore(strComputerName,strSGName,strMDBName)' Bind to the Exchange ServeriServer.DataSource.OpenstrComputerName' Build the first part of the URL to the MailboxStoreDBstrTemp="LDAP://"&iServer.DirectoryServer&"/"&"cn="&strMDBName&","' Set variant array to the ExchangeServer.StorageGroupsarrStGroup=iServer.StorageGroups' Look in the StorageGroups array if the StorageGroup with strSGName existsIfstrSGName=""Then' Add last part to the URL to the MailboxStoreDBstrMDBUrl=strTemp&iServer.StorageGroups(0)ElseFori=0ToUBound(arrStGroup)IfInStr(1,UCase(arrStGroup(i)),UCase(strSGName))<>0ThenstrMDBUrl=arrStGroup(i)EndIfNextIfstrMDBUrl<>""Then' Add last part to the URL to the MailboxStoreDBstrMDBUrl=strTemp&strMDBUrlEndIfEndIf' Bind to the MailboxStoreDBiMDB.DataSource.OpenstrMDBUrl', , , adCreateOverwriteEndSubSubGetArgs(strMode,strComputerName,strSGName,strMDBName,CorrectSyntax)SetArgs=WScript.ArgumentsIfargs.count=4ThenCorrectSyntax=TruestrMode=args(0)strComputerName=args(1)strSGName=args(2)strMDBName=args(3)ElseCorrectSyntax=FalseEndIfSelectCaselcase(strMode)Case"mount","dismount","delete"CorrectSyntax=TrueCase"/?","/help","?","help"CorrectSyntax=FalseEndSelectEndSubSubDisplayHelpwscript.echo"Mounts, Dismounts, or Deletes a Mailbox Store on an Exchange 2000/2003 server"wscript.echo""wscript.echo"cscript StoreDB.vbs /? or /Help ----------------------------------- Displays this help screen"wscript.echo"cscript StoreDB.vbs Mount Servername StorageGroupName MDBName ----- Mounts Database"wscript.echo"cscript StoreDB.vbs Dismount Servername StorageGroupName MDBName -- Dismounts Database"wscript.echo"cscript StoreDB.vbs Delete Servername StorageGroupName MDBName ---- Deletes Database"wscript.echo""wscript.echo""wscript.echo"Example:"wscript.echo""wscript.echo"cscript StoreDB.vbs Mount SERVER1 "&quot&"First Storage Group"&quot&" "&quot&"Mailbox Store (SERVER1)"&quotwscript.echo""EndSub