Solved

Mount information store with VB script

Posted on 2010-08-20
6
491 Views
Last Modified: 2012-05-10
I found this script here on experts Exchange, but my complete lack of knowledge in VB scripts is making me cautious of just slapping it to my exchange server. I'm hoping someone that has used the script before or knows about VB can help me out a little bit.

http://exchange.mvps.org/E2K3/mount%20a%20store%20via%20cmd.htm 

First question, what section do I need to copy, as it says part of it are for deleting. Second qestion, can someone show me what the VB script should look like if my server name is server123 and the name of the store I want to mount is called PublicStore?
0
Comment
Question by:JacobC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 32

Expert Comment

by:endital1097
ID: 33487223
first i would update it to below

looking at the script you are going to execute it by typing the following at a command prompt and it will prompt for info

cscript script.vbs
Dim strMDBName
Dim strSGName
Dim strComputerName
Dim strAdmGrpName
Dim OrgName
Dim LdapDc

strMDBName = InputBox ("Name of the MDB to be dismounted","Mailbox Store
Name","Mailbox store (Server-A)")
strSGName = InputBox ("Name of the storage group that contains the
MDB","Storage Grop name","First storage group")
strComputerName = InputBox ("Name of the Exchange 2000 server","Server
Name","Server-a")
strAdmGrpName = InputBox ("Name Of the administrative group","Admin Group
name","First Administrative Group")
OrgName = InputBox ("Enter the Organization Name","Organization","NorthWind
Traders")
LdapDc = InputBox ("Enter LDAP Domain
Name","Dc=Domain,Dc=msft","DC=NorhWind,DC=Traders")

' Sub DismountMailboxStoreDB (strMDBName,strSGName,strComputerName )

Dim iMDB
Dim iServer
Dim strTemp
Dim strMDBUrl
Dim arrStGroup()

set iServer = CreateObject ("CDOEXM.ExchangeServer")
set iMDB = CreateObject ("CDOEXM.MailboxStoreDB")
iServer.DataSource.Open strComputerName
WScript.echo iServer.DirectoryServer

' Build the URL to the MailboxStoreDB
    strMDBUrl =
"LDAP://"&iServer.DirectoryServer&"/"&"cn="&strMDBName&",cn="&strSGName&",cn=InformationStore,cn="&strComputerName&",CN=Servers,CN=" &strAdmGrpName& ",CN=Administrative Groups,CN="&OrgName&",CN=Microsoft Exchange,CN=Services,CN=Configuration,"& LdapDc
WScript.echo  "the url is  " & strMDBUrl

'Bind to the MailboxStoreDB
    iMDB.DataSource.Open strMDBUrl

'Dismount the MailboxStoreDB
    iMDB.Dismount(30)
    WScript.echo "The database "& strMDBName & " was successfuly dismounted"

'Cleanup
    Set iServer = Nothing
    Set iMDB = Nothing

Open in new window

0
 
LVL 32

Expert Comment

by:endital1097
ID: 33487253
or you could take the top half and run it from a command prompt using

cscript script.vbs mount server123 "First Storage Group" PublicStore


the first was dismount, you need to change the script from iMDB.Dismount(30) to iMDB.Mount
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)
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

Open in new window

0
 

Author Comment

by:JacobC
ID: 33488072
I dont see the server name or public folder name in either script set. I dont need to designate the IS i am trying to mount or the server?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Expert Comment

by:endital1097
ID: 33489505
the first script will prompt you for the information

the second script you must call with the parameters as I showed before
the format for the parameters is:
mount/unmount servername storagegroup database

cscript script.vbs mount server123 "First Storage Group" PublicStore
0
 

Author Comment

by:JacobC
ID: 33512365
What if I want the information to be automaticly put in?
0
 
LVL 32

Accepted Solution

by:
endital1097 earned 500 total points
ID: 33512986
see script below
quot = chr(34) 

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

strMode = "mount"
strComputerName = "server123"
strSGName = "First Storage Group"
strMDBName = "PublicStore"
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

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

Open in new window

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question