[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Script to populate/generate MAILBOXES.TXT

Posted on 2006-05-11
4
Medium Priority
?
1,071 Views
Last Modified: 2012-08-14
Hello

Does anyone have a VBS script which will automatically populate the MAILBOXES.TXT file which is used by exmerge?

I need to run a scheduled task which imports a permission into every users mailbox using exmerge.

I have found a script which generates each users pst file, by copying a template pst file I have created (which includes the relevant permission change)

I can also script the Exmerge command, but need the mailboxes.txt file to automatically update with all the entire mailbox list.

The sort of thing I want it to generate is this:
/O=DOMAIN/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=JOE.BLOGGS

for each user.

Any ideas?

Thanks

Rich
0
Comment
Question by:ScintillateRich
  • 3
4 Comments
 
LVL 31

Accepted Solution

by:
LeeDerbyshire earned 408 total points
ID: 16657974
Try this.  You'll need to change any yourdomain and any com bits:

  Set objConn = CreateObject("ADODB.Connection")
  objConn.Provider = "ADsDSOObject"
  objConn.Properties("ADSI Flag") = 33 ' 1
  objConn.Open "ADs Provider"
  Set objCmd = CreateObject("ADODB.Command")
  objCmd.ActiveConnection = objConn
  strSQL = "<LDAP://CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Container,CN=yourdomain,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=yourdomain,DC=com>;;purportedSearch"
  objCmd.CommandText = strSQL
  Set objRs = objCmd.Execute
  strSearch = objRs("purportedSearch")
  strSQL = "<GC://DC=yourdomain,DC=com>;(&"
  strSQL = strSQL & strSearch & "(!(msExchHideFromAddressLists=TRUE)))"
  strSQL = strSQL & ";legacyExchangeDN"
  objCmd.CommandText = strSQL
  objCmd.Properties("Sort on") = "displayName"
  Set objRs = objCmd.Execute
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.OpenTextFile("C:\test.txt", 2, True)
  Do While Not(objRs.EOF)
    f.WriteLine objRs("legacyExchangeDN")
    objRs.MoveNext
  Loop
  f.Close
  Set f = Nothing : Set fso = Nothing
  Set objConn = Nothing : Set objCmd = Nothing : Set objRs = Nothing
0
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 16658004
Um, hang on.  Which version of Exchange?  I assumed 2003 here.
0
 
LVL 2

Author Comment

by:ScintillateRich
ID: 16659613
Thank you so much for your help!

Is there anyway I can stop the script outputing security and distribution groups?

Thanks

Rich
0
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 16659741
Well, it's based around the GAL purportedSearch, so you could ignore that, and build your own query.  Instead of

  strSearch = objRs("purportedSearch")

you could try

  strSearch = (&(objectCategory=person)(objectClass=user)(mailnickname=*))

It's very hard to predict what you'll get with these things.  Let me know what this one returns.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Stellar Exchange Toolkit: this 5 in 1 toolkit comes loaded with mega-software tool. Here’s an introduction to tools’ usage and advantages:
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 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