Announcement

Collapse
No announcement yet.

Select Mailboxstore of one Administrative Group

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select Mailboxstore of one Administrative Group

    Hi all,

    I have found a script which list and display all mailbox store and i want to just select mailbox store of all server in administrative group.

    See the script below :

    On Error Resume Next
    SelectMailStore()

    '//////////////////////////////////////////////////
    Function SelectMailStore()
    'On Error Resume Next
    Dim objRootDSE
    Dim objConfiguration
    Dim cat
    Dim conn
    Dim cmd
    Dim RS
    Dim objDict,strConfiguration,strQuery,x,strDNSrv,strMb x
    x=1

    Set objDict=CreateObject("scripting.dictionary")
    Set objRootDSE = GetObject("LDAP://rootDSE")

    'strDNSrv="CN=EMCU90MX1,CN=Servers,CN=EuropeHQ,CN= Administrative Groups,CN=CIB,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=ad,DC=cib "
    'strMbx="CN=EVS3SG1IS1,CN=EVS3SG1,CN=InformationSt ore,CN=EMCU90MX1,CN=Servers,CN=EuropeHQ,CN=Adminis trative Groups,CN=CIB,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=ad,DC=cib "

    strConfiguration = "LDAP://" & objRootDSE.Get("configurationNamingContext")
    Set objConfiguration = GetObject(strConfiguration)
    strQuery="Select name,cn,distinguishedname from '" & objConfiguration.ADSPath & "'Where objectclass='msExchPrivateMDB'"

    set cat=GetObject("GC:")
    for each obj in cat
    set GC=obj
    Next

    AdsPath=GC.ADSPath

    set conn=CreateObject("ADODB.Connection")
    set cmd=CreateObject("ADODB.Command")
    conn.Provider="ADSDSOObject"
    conn.Open

    Set cmd.ActiveConnection=conn
    Set RS=conn.Execute(strQuery)

    do while Not RS.EOF
    DN=rs.Fields("distinguishedname")
    CN=RS.Fields("cn")
    NM=RS.Fields("name")
    ' WScript.Echo "Name: " & NM
    ' WScript.Echo "CN: " & CN
    objDict.Add x,DN
    strResults=strResults &"(" & x & ") " &DN & vbCrLf
    x=x+1
    rs.movenext
    Loop
    rs.Close
    conn.Close
    t=1

    a=objDict.Items
    For i=0 To objDict.Count-1
    c=c & "(" & i+1 & ")" & " " & a(i) & VbCrLf & vbCrLf
    'display available mailbox stores in groups of 4
    If t<>4 And i<>objDict.count-1 Then
    t=t+1
    Else
    MsgBox c,vbOKOnly,"Banques de boîtes aux lettres disponibles"
    t=1
    c=""
    End If
    Next

    iDN=Inputbox("Entrer le numéro correspondant à la Mailbox Store.","Sélectionner la Mailbox Store","0")
    If iDN = "" Then
    MsgBox "Rien n' a été entré ou vous avez annulé l'opération.",vbExclamation,"AVERTISSEMENT"
    WScript.Quit
    End If

    If objDict.Exists(Int(iDN)) Then
    SelectMailStore=objDict.Item(Int(iDN))
    Else
    rc=MsgBox ("Nombre invalide. Veuiller relancer le script.",vbExclamation,"AVERTISSEMENT")
    if rc=vbCancel Then
    wscript.Quit
    Else
    Main()
    End If
    End If

    Set objRootDSE=Nothing
    Set objConfiguration=Nothing
    Set cat=Nothing
    Set conn=Nothing
    Set cmd=Nothing
    Set RS=Nothing
    Set objDict=Nothing
    End Function

    MsgBox "Fin du script", vbInformation, "Information"
    WScript.Quit

    I think i need to change this line :

    strQuery="Select name,cn,distinguishedname from '" & objConfiguration.ADSPath & "'Where objectclass='msExchPrivateMDB'"

    By something like that but it doesnt work:

    strQuery="Select name,cn,distinguishedname from '" & objConfiguration.ADSPath & "'Where objectclass='msExchPrivateMDB'" and "objectclass=msExchAdminGroupCN=EuropeHQ,CN=Admini strative Groups,CN=CIB,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=ad,DC=cib "

    Thanks

    Thomas
Working...
X