April 24, 2002 10:24 PM

Troubleshooter: Dismounting an Exchange 2000 Database from the Command Line

Rating: (0)
Windows IT Pro
InstantDoc ID #24788

I'm writing management scripts for use on our Exchange 2000 Server systems. Do you know of a way to dismount a database from the command line?

Exchange 2000 includes a new set of management interfaces. In addition to the Collaboration Data Objects (CDO) library, Exchange 2000 includes the CDO for Exchange Management (CDOEXM) library. CDOEXM implements several interfaces that let you perform tasks relating to your servers, storage groups...

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

I have updated the utility. It now supports Public Folders. Email me to recieve it...

Leon6/10/2005 9:05:40 AM


um - oops. Looks like it wont let me paste it correctly. If you want the code email me at leon_funnell(AT)hotmail(d0t)com...

Leon2/17/2005 10:23:47 AM


Answer:
a) Learn Vbscript and make a command line utility
b) Use the one I wrote below:

' Name: StoreDB.VBS
' Purpose: To Mount, Dismount, or Delete a Mailbox Store (MDB) on Exchange Server
'
'Written by Leon Funnell
'email me at leon_funnell(At)hotmail(d0t)com
'17/02/2005
'
'

quot = chr(34)

Set iServer = CreateObject ("CDOEXM.ExchangeServer")
Set iMDB = CreateObject ("CDOEXM.MailboxStoreDB")

' check command line
GetArgs strMode,strComputerName,strSGName,strMDBName,CorrectSyntax
If CorrectSyntax Then
BindMailboxStore strComputerName,strSGName,strMDBName
Select Case strMode
Case "mount"
wscript.echo "Mounting Database " & strMDBName & " in Storage Group " & strSGName & " on " & strComputerName
iMDB.mount
Case "dismount"
wscript.echo "Dismounting Database " & strMDBName & " in Storage Group " & strSGName & " on " & strComputerName
iMDB.dismount
Case "delete"
wscript.echo "Deleting Database " & strMDBName & " in Storage Group " & strSGName & " on " & strComputerName
iMDB.DataSource.delete
End Select

' Cleanup
Set iServer = Nothing
Set iMDB = Nothing
Else
DisplayHelp
wscript.quit
End If

Sub BindMailboxStore (strComputerName,strSGName,strMDBName)
' Bind to the Exchange Server
iServer.DataSource.Open strComputerName

' Build the first part of the URL to the MailboxStoreDB
strTemp = "LDAP://" & iServer.DirectoryServer & "/" & "cn=" & strMDBName & ","

' Set variant array to the ExchangeServer.StorageGroups
arrStGroup = iServer.StorageGroups

' Look in the StorageGroups array if the StorageGroup with strSGName exists
If strSGName = "" Then
' Add last part to the URL to the MailboxStoreDB
strMDBUrl = strTemp & iServer.StorageGroups(0)
Else
For i = 0 To UBound(arrStGroup)
If InStr(1, UCase(arrStGroup(i)), UCase(strSGName)) <> 0 Then
strMDBUrl = arrStGroup(i)
End If
Next
If strMDBUrl <> "" Then
' Add last part to the URL to the MailboxStoreDB
strMDBUrl = strTemp & strMDBUrl
End If
End If
' Bind to the MailboxStoreDB
iMDB.DataSource.Open strMDBUrl ', , , adCreateOverwrite
End Sub


Sub GetArgs(strMode,strComputerName,strSGName,strMDBName,CorrectSyntax)
Set Args = WScript.Arguments
If args.count = 4 Then
CorrectSyntax = True
strMode = args(0)
wscript.echo strmode
strComputerName = args(1)
strSGName = args(2)
strMDBName = args(3)
Else
CorrectSyntax = False
End If
Select Case lcase(strMode)
Case "mount","dismount","delete"
CorrectSyntax = True
Case "/?","/help","?","help"
CorrectSyntax = False
End Select
End Sub


Sub DisplayHelp
wscript.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 ""&"First Storage Group""&" ""&"Mailbox Store (SERVER1)""
wscript.echo ""
End Sub


Leon2/17/2005 10:22:20 AM


This article doesn't answer the original question. Is it possible to dismount a store from a command line, without programming?

Michael Shire 10/23/2003 7:36:04 AM


This article was absolutely no help. He answers the problem of mounting X-change DB's from the command line by pointing you to the MSDN and building API objects. So much for the command line!

brian8/5/2002 4:55:29 PM


You must log on before posting a comment.

Are you a new visitor? Register Here
GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS