?
Solved

Exchange 2003 Script

Posted on 2011-05-09
11
Medium Priority
?
349 Views
Last Modified: 2012-05-11
Hi All,

I have an excel spreadsheet which contains a list of Exchange users that need migrating from exchange 2003 to 2010. The spreadsheet contains sAMAccountName and email address.

How, using my data above, can I get the mailbox size for only the users in the spreadsheet?

Hope someone can help as I have 5000 users to migrate :-s
0
Comment
Question by:ijwrighty
  • 5
  • 5
11 Comments
 
LVL 8

Expert Comment

by:ckeshav
ID: 35718892
You can just export this from Exchange 2003 Management console.
Under the Exchange Management Console, navigate to the Mailbox folder, Right-Click and export to a excel file or .csv file

This will give the sAMAccountName, email address, Mailbox size
0
 
LVL 9

Expert Comment

by:Ahmed786
ID: 35719012
Or either you can use below VB script and follow some command as below to tranfer it to Excel and sort them.

You be an Admin account holder

1> Save below script as listallmailboxes.vbs in you C or D drive and then
2> Open Command Prompt --> Go to c:\>listallmailboxes.vbs > listallmailboxes.txt (then press enter)
3> Then open Excel sheet and file --> Open --> select listallmailboxes.txt from C drive --> then select Delimited --> Next --> tick on Semicolon --> then Next --> Finish.
4> You can use filter button to filter the highest size of the mailbox.




' Name : listallmailboxes.vbs
      ' Description : script to enumerate all mailboxes and their size in your AD domain

      
      Set adoCommand = CreateObject("ADODB.Command")
      Set adoConnection = CreateObject("ADODB.Connection")
      adoConnection.Provider = "ADsDSOObject"
      adoConnection.Open "Active Directory Provider"
      adoCommand.ActiveConnection = adoConnection
      
      Set objRootDSE = GetObject("LDAP://RootDSE")
      strBase = "<LDAP://" & objRootDSE.Get("configurationnamingcontext") & ">"
      strFilter = "(objectCategory=msExchExchangeServer)"
      strAttributes = "name"
      
      strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
      adoCommand.CommandText = strQuery
      adoCommand.Properties("Page Size") = 100
      adoCommand.Properties("Timeout") = 30
      adoCommand.Properties("Cache Results") = False
      
      Set adoRecordset = adoCommand.Execute
      
      Do Until adoRecordset.EOF
          Set objWMIExchange = GetObject("winmgmts:{impersonationLevel=impersonate}!//"&_
          adoRecordset.Fields("name").Value & "/root/MicrosoftExchangeV2")
          Set colExchangeMailboxes = objWMIExchange.InstancesOf("Exchange_Mailbox")
          For Each objExchangeMailbox in colExchangeMailboxes
              If Left(objExchangeMailbox.StorageGroupName, 5) <> "Recov" Then
                  Wscript.Echo adoRecordset.Fields("name").Value & " ; " & objExchangeMailbox.MailboxDisplayName & " ; " &_
                  Round(objExchangeMailbox.Size/1024,0) & " MB"
              End If
          Next
          Set colExchange_Mailboxes = Nothing
          Set objWMIExchange = Nothing
          adoRecordset.MoveNext
      Loop
      
      adoRecordset.Close
      adoConnection.Close
      
      Set adoRecordset = Nothing
      Set objRootDSE = Nothing
      Set adoConnection = Nothing
      Set adoCommand = Nothing
0
 

Author Comment

by:ijwrighty
ID: 35719093
Thanks for response. My issue is I actually have 10000 users but my customer has narrowed down the list is narrowed to 5000 users. I need to get mailbox stats from this list of 5000 users.

Thanks
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
LVL 9

Expert Comment

by:Ahmed786
ID: 35721230
Could you please provide the example of excel sheet pls ? as wht your are looking for.

as samaccount name is the Logon name and email address as SMTP address.

So we have to put the same in the script.

pls paste the excel sheet, to understand properly.
0
 

Author Comment

by:ijwrighty
ID: 35721725
Exch Users
0
 

Author Comment

by:ijwrighty
ID: 35721727
Above is example.
0
 
LVL 9

Expert Comment

by:Ahmed786
ID: 35727888
In the above example Bloggs Joe  is an display name ?
0
 

Author Comment

by:ijwrighty
ID: 35728148
Yes it is :-)
0
 
LVL 9

Accepted Solution

by:
Ahmed786 earned 2000 total points
ID: 35745558
Take the final script.

Have made some amendment, save this script as example.vbs or anything and also make sure to give the path of your excel sheet (means do editing in the 4th Row of the script)

After executing it will show you in the command prompt and then after completion of it will ask you to save it, click yes and then you will find another 2 columns one for exchange servername and other for mailbox size in your excel sheet.

Note :- Make sure that your SMTP email address is in SECOND COLUMN of your excel sheet and then you will get  output on 7th and 8th COLUMN of your excel sheet.

Dim strDisplayName, strHomeMDB
Dim strSMTP

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\New_users1.xls")
intRow = 2
      
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
 
Set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://" & objRootDSE.Get("configurationnamingcontext") & ">"
strFilter = "(objectCategory=msExchExchangeServer)"
strAttributes = "name"
 
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
'Set adorecordset= CreateObject("ADODB.Recordset")
Set adoRecordset = adoCommand.Execute

Do Until objExcel.Cells(intRow,2).Value = ""
WScript.Echo objexcel.cells(intRow,2).Value
strSMTP=objExcel.cells(intRow,2).value
GetDisplayNameAndHomeMDB(strSMTP)
      Do Until adoRecordset.EOF
    If Instr(strHomeMDB,adoRecordset.Fields("name").Value) > 1 Then
        Set objWMIExchange = GetObject("winmgmts:{impersonationLevel=impersonate}!//"&_
        adoRecordset.Fields("name").Value & "/root/MicrosoftExchangeV2")
        Set colExchangeMailboxes = objWMIExchange.ExecQuery("Select * From Exchange_Mailbox Where MailboxDisplayName = '" & strDisplayName & "'")
        For Each objExchangeMailbox in colExchangeMailboxes
            If Left(objExchangeMailbox.StorageGroupName, 5) <> "Recov" Then
                Wscript.Echo adoRecordset.Fields("name").Value & " ; " & objExchangeMailbox.MailboxDisplayName & " ; " &_
                Round(objExchangeMailbox.Size/1024,0) & " MB"
                objExcel.Cells(intRow,7).Value = adoRecordset.Fields("name")
                objExcel.Cells(intRow,8).Value = Round(objExchangeMailbox.Size/1024,0) & " MB"
            End If
        Next
        Set colExchange_Mailboxes = Nothing
        Set objWMIExchange = Nothing
    End If
    adoRecordset.MoveNext
      Loop
      intRow =intRow + 1
      Set adoRecordset = adoCommand.Execute
Loop
adoRecordset.Close
adoConnection.Close
objworkbook.Close

 
Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
      
Function GetDisplayNameAndHomeMDB(strMail)
    Set adoCommand1 = CreateObject("ADODB.Command")
    Set adoConnection1 = CreateObject("ADODB.Connection")
    adoConnection1.Provider = "ADsDSOObject"
    adoConnection1.Open "Active Directory Provider"
    adoCommand1.ActiveConnection = adoConnection1
 
    Set objRootDSE1 = GetObject("LDAP://RootDSE")
    strDNSDomain1 = objRootDSE1.Get("defaultNamingContext")
    strBase1 = "<LDAP://" & strDNSDomain1 & ">"
    strFilter1 = "(&(objectCategory=person)(objectClass=user)(mail=" &  strMail & "))"
    strAttributes1 = "displayName,homeMDB"
 
    strQuery1 = strBase1 & ";" & strFilter1 & ";" & strAttributes1 & ";subtree"
    adoCommand1.CommandText = strQuery1
    adoCommand1.Properties("Page Size") = 100
    adoCommand1.Properties("Timeout") = 30
    adoCommand1.Properties("Cache Results") = False
 
    Set adoRecordset1 = adoCommand1.Execute
    strDisplayName = adoRecordset1.Fields("displayName").Value
    strHomeMDB = adoRecordset1.Fields("homeMDB").Value
    adoRecordset1.Close
    adoConnection1.Close       
      Set adoRecordset1 = Nothing
    Set objRootDSE1 = Nothing
    Set adoConnection1 = Nothing
    Set adoCommand1 = Nothing
End Function
0
 

Author Comment

by:ijwrighty
ID: 35792047
Perfect
0
 
LVL 9

Expert Comment

by:Ahmed786
ID: 35792318
Is the above script worked as wht u want ?
0

Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

Question has a verified solution.

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

In my humble opinion (IMHO), TouchDown from Symantec is the best in class for this type of application, but Symantec has end-of-lifed it and although one can keep using it, it will no longer be supported or upgraded.  Time to look for alternatives t…
The article explains the process to deploy a Self-Service password reset portal I developed a few years ago. Hopefully, it will prove useful to someone.  Any comments, bug reports etc. are welcome...
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

612 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