Export/Import Public Folder Email Addresses

Posted on 2009-02-16
Last Modified: 2012-05-06
A company recently merged with another company and we are inthe process of performing a cross forest migration. While all is done, there is one step that i need some help with.

we have over 13000 public folders that have been replicated using the inter-org replication tool. The problem here is that, around 5000 of them are mail-enabled.

Without going through all of them manually, is there an easy way to add additional smtp (proxyaddresses) to all of them. Or export that list from the old forest and import into the new forest? All folders have the same name, but are in the new forest.

Any suggestions are appreciated.

Question by:advserver
    LVL 57

    Assisted Solution

    by:Mike Kline
    ADModify may be what you need for this
    A good overview here
    I've used admodify in production but never for public folders and I don't have any in my lab to test with or I would.
    Seems like you should be able to add the address.
    Hope that helps
    LVL 4

    Author Comment

    i have used admodify 1.6 and 2.0, but like you never for public folders, i did query the directory and found 1619 public folders, i am wondering why i only found that many. I am sure that i have over 5000 that are mail enabled.

    i was trying to think of a way to update these via RUS, but that doesnt appear to be working, even if i use admodify and select update based on RUS.

    LVL 57

    Expert Comment

    by:Mike Kline
    That is interesting;
    I wonder if an adfind command would find mroe
    something like
    adfind -default -f  "&(objectcategory=publicfolder)(proxyaddresses=*)"
    Wish I had a system with mail enabled public folders to test this on.
    LVL 11

    Assisted Solution

    strComputer = "."
    strFile = "C:\Documents and Settings\ekrengel\Desktop\Public Folder Script\Public Folders.xls"
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _

    Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_PublicFolder")

    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = False
    objExcel.Cells(1,1).Value = "All Public Folder in Domain "
    objExcel.Cells(1,1).Font.Bold = True
    objExcel.Cells(1,1).Font.Size = 13
    objExcel.Cells(1,1).Interior.ColorIndex = 11
    objExcel.Cells(1,1).Interior.Pattern = 1 'xlSolid
    objExcel.Cells(1,1).Font.ColorIndex = 2
    objExcel.Cells(1,1).Borders.LineStyle = 1 '= xlSolid
    objExcel.Cells(1,1).WrapText = True

    objExcel.Cells(2,1).Value = "Time: " & Now
    objExcel.Cells(2,1).Font.Bold = True
    objExcel.Cells(2,1).Font.Size = 12
    objExcel.Cells(2,1).Interior.ColorIndex = 11
    objExcel.Cells(2,1).Interior.Pattern = 1 'xlSolid
    objExcel.Cells(2,1).Font.ColorIndex = 2
    objExcel.Cells(2,1).Borders.LineStyle = 1 '= xlSolid
    objExcel.Cells(2,1).WrapText = True

    objExcel.Cells(4,1).Value = "Folder Name"
    objExcel.Cells(4,1).Font.Bold = True
    objExcel.Cells(4,1).Font.Size = 11
    objExcel.Cells(4,2).Value = "Email Address"
    objExcel.Cells(4,2).Font.Bold = True
    objExcel.Cells(4,2).Font.Size = 11
    objExcel.Cells(4,3).Value = "Creation Time"
    objExcel.Cells(4,3).Font.Bold = True
    objExcel.Cells(4,3).Font.Size = 11

    x = 5
    y = 1

    For Each PFolder in colItems
    strProxyAddresses = "IsMailEnabled= False"
    strDisplayName = PFolder.AddressBookName
    strSecondary = ""
    Secondary = ""
    If PFolder.IsMailEnabled=TRUE then
    strProxyAddresses = GetProxies(strDisplayName)
    End If

    y1 = y
    objExcel.Cells(x,y1).Value = strDisplayName
    y1 = y1 + 1
    objExcel.Cells(x,y1).Value = strProxyAddresses
    y1 = y1 + 1
    objExcel.Cells(x,y1).Value = PFolder.CreationTime
    x = x + 1 'go to the next Row


    objExcel.Selection.HorizontalAlignment = 3 'xlCenter
    objExcel.Selection.Borders.LineStyle = 1 '= xlSolid

    objExcel.Range("A1","C1").MergeCells = 1
    objExcel.Range("A2","C2").MergeCells = 1


    objExcel.DisplayAlerts = False
    Set objWorkbook = objExcel.ActiveWorkbook
    objWorkbook.SaveAs strFile

    msgbox "Script Complete!"


    Function GetProxies(AddressBookName)
    on error resume next
    Primary = ""
    Secondary = ""
    Set rootDSE = GetObject("LDAP://RootDSE")
    DomainContainer = rootDSE.Get("defaultNamingContext")

    Set conn = CreateObject("ADODB.Connection")
    conn.Provider = "ADSDSOObject"
    conn.Open "ADs Provider"

    ldapStr = "<LDAP://" & DomainContainer & ">;(&(&(&(&" & _
    "(| (objectCategory=publicFolder) )))(objectCategory=publicFolder)" & _
    "(displayName="& AddressBookName &")));adspath;subtree"

    Set rs = conn.Execute(ldapStr)

    Set oPublicFolder = GetObject(rs.Fields(0).Value)

    For each email in oPublicFolder.proxyAddresses
    If Left(email,5) = UCase("SMTP:") Then
    Primary = Mid (email,6)
    'Exit For
    ElseIf Left(email,5) = LCase("smtp:") Then
    Secondary = Mid (email,6) & "; " & Secondary
    End If
    If Err.number then _
    Primary = Mid (oPublicFolder.proxyAddresses,6)

    GetProxies = Primary

    End Function
    LVL 4

    Author Comment

    thanks for the script sandeep, could you explain a bit more on this for me please.
    it appears to be two scripts. any additional assistance would be greatly appreciated.

    LVL 11

    Expert Comment

    There's only one script at the end i have two functions
    LVL 4

    Author Comment

    thanks again, i will try this in my lab. I will let you know
    LVL 4

    Author Comment

    i put the script on my exchange server as a .vbs and ran in, the command shell appears and that is about all. Could you possibly provide additional instructions for me?
    LVL 4

    Accepted Solution

    i have resolved this myself..but it did take a script.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Set up iPhone and iPad email signatures to always send in high-quality HTML with this step-by step guide.
    Easy CSR creation in Exchange 2007,2010 and 2013
    In this video we show how to create an Accepted Domain 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 Mail Flow >> Ac…
    In this video we show how to create an email address policy 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 Mail Flow…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now