?
Solved

I want to get all the mailboxes which are more than 20 MB

Posted on 2007-07-27
9
Medium Priority
?
567 Views
Last Modified: 2008-01-09


Hi,

I want to get all the mailboxes which are more than 20 MB.Is there a way i can run a script which can fetch the exchange  with all these details.

Name ,Mailbox size ,Email address,Storage name, Date last logged in.

Regards
Sharath
0
Comment
Question by:bsharath
9 Comments
 
LVL 29

Expert Comment

by:mass2612
ID: 19583805
Hi,

Do you know any vbScripting? If so you should be able to modify this pretty easily. If not I could modify it but I have no way to test it over the weekend.

http://techtasks.com/code/viewbookcode/1246
0
 
LVL 11

Author Comment

by:bsharath
ID: 19583844
No idea about scripting...
0
 
LVL 29

Expert Comment

by:mass2612
ID: 19583866
Hi again,

I made some changes to the above no SMTP address but everything else should be ok to a csv file output. test this here. Save the script in the same location where you want the output file to be stored and then run it using : -

cscript scriptname.vbs

http://techtasks.com/code/viewbookcode/1246

' START Script
' ------ SCRIPT CONFIGURATION ------
 strComputerName = "<serverName>"      ' e.g. "batman"
 OutputFile = "MailboxSize.csv"      ' Output file with server details
' ------ END CONFIGURATION ---------
  strE2K3WMIQuery = "winmgmts://" & strComputerName &_
    "/root/MicrosoftExchangeV2"
  Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.OpenTextFile(OutputFile, forWriting, True) ' opens output file for writing
objOutputFile.WriteLine "Display Name, Mailbox Size in KB, Store Name, Last Logon, No of Items" ' writes header names to output file
 
  ' Find each mailbox on the target server and report their
  ' Name , size in KB, store name
  Set mboxList = GetObject(strE2K3WMIQuery).InstancesOf("Exchange_Mailbox")
 
  For each mailbox in mboxList
        If mailbox.Size >= 20000 Then
              strOutput = mailbox.MailboxDisplayName & "," & mailbox.Size & "," & mailbox.StoreName & "," & mailbox.LastLogonTime & "," & mailbox.TotalItems
                objOutputFile.WriteLine strOutput
        Else
        
  Next
'END Script
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 19

Expert Comment

by:weellio
ID: 19583875
try this one

' From the book "Active Directory, Third Edition"
' ISBN: 0-596-10173-2

'This script dumps all store details of all mailboxes in an
'Exchange ORG to a text file in semi-colon delimited format
Option Explicit
Dim objConn, objComm, objRS
Dim strBase, strFilter, strAttrs, strScope
Dim fso, outfile
Dim strComputer, objWMI, objMbx, objMbxs
' ------ SCRIPT CONFIGURATION ------
strConfigDN = "<Exchange Server>" 'e.g. cn=configuration,dc=mycorp,dc=com
' ------ END CONFIGURATION ---------
'**********************************************************************
'Set the ADO search criteria
'**********************************************************************
strBase   = "<LDAP:// " & strConfigDN & ">;"
strFilter = "(objectcategory=msExchExchangeServer);"
strAttrs  = "name;"
strScope  = "Subtree"
set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open
'**********************************************************************
'Need to enable Paging in case there are more than 1000 objects returned
'**********************************************************************
Set objComm = CreateObject("ADODB.Command")
Set objComm.ActiveConnection = objConn
objComm.CommandText = strBase & strFilter & strAttrs & strScope
objComm.Properties("Page Size") = 1000
Set objRS = objComm.Execute()
'**********************************************************************
'Create a VBScript file object and use it to open a text file. The
'second parameter specifies to overwrite any existing file that exists.
'**********************************************************************
Set fso = CreateObject("Scripting.FileSystemObject")
Set outfile = fso.CreateTextFile("c:\out.txt", TRUE)
'**********************************************************************
'Write header line to file
'**********************************************************************
outfile.WriteLine "LegacyDN;" _
                  & "MailBoxGUID;" _
                  & "ServerName;" _
                  & "StorageGroupName;" _
                  & "StoreName;" _
                  & "AssocContentCount;" _
                  & "DateDiscoveredAbsentInDS;" _
                  & "DeletedMessageSizeExtended;" _
                  & "LastLoggedOnUserAccount;" _
                  & "LastLogoffTime;" _
                  & "LastLogonTime;" _
                  & "Size;" _
                  & "StorageLimitInfo;" _
                  & "TotalItems"
'**********************************************************************
'Loop through all servers and dump all store info for all mailboxes
'**********************************************************************
While Not objRS.EOF
  strComputer = objRS.Fields.Item("name").Value
  Set objWMI = GetObject("winmgmts:\\" & strComputer & _
                       "\root\MicrosoftExchangeV2")
  Set objMbxs = objWMI.ExecQuery("Select * from Exchange_Mailbox",,48)
  For Each objMbx In objMbxs
    outfile.Write objMbx.LegacyDN
    outfile.Write ";" & objMbx.MailboxGUID
    outfile.Write ";" & objMbx.ServerName
    outfile.Write ";" & objMbx.StorageGroupName
    outfile.Write ";" & objMbx.StoreName
    outfile.Write ";" & objMbx.AssocContentCount
    outfile.Write ";" & objMbx.DateDiscoveredAbsentInDS
    outfile.Write ";" & objMbx.DeletedMessageSizeExtended
    outfile.Write ";" & objMbx.LastLoggedOnUserAccount
    outfile.Write ";" & objMbx.LastLogoffTime
    outfile.Write ";" & objMbx.LastLogonTime
    outfile.Write ";" & objMbx.Size
    outfile.Write ";" & objMbx.StorageLimitInfo
    outfile.WriteLine ";" & objMbx.TotalItems
  Next
  objRS.MoveNext
Wend
outfile.Close

0
 
LVL 11

Author Comment

by:bsharath
ID: 19583884
I get this.

---------------------------
Windows Script Host
---------------------------
Script:      C:\Mailbox details.vbs
Line:      22
Char:      3
Error:      Unexpected 'Next'
Code:      800A041F
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------
0
 
LVL 29

Expert Comment

by:mass2612
ID: 19583920
What version of Exchange are you using?
0
 
LVL 39

Expert Comment

by:redseatechnologies
ID: 19583977
Does it have to be a script?

Open up exchange system manager, browse to your server, open up the mailbox resources, and export them to a TXT file

-red
0
 
LVL 27

Expert Comment

by:Exchange_Admin
ID: 19585356
I agree with Red. Why complicate matters when the info you are asking for is readily availiable?

I try to subscribe to the K.I.S.S. philosphy.

Russ
0
 
LVL 29

Accepted Solution

by:
mass2612 earned 2000 total points
ID: 19586681
This one's been tested and works ok. If you want to run it again simply rename the existing output file as it creates the file and if it exists it will error.

' START Script
' ------ SCRIPT CONFIGURATION ------
 strComputerName = "lab1ex1"      ' e.g. "batman"
 OutputFile = "MailboxSize.csv"      ' Output file with server details
' ------ END CONFIGURATION ---------
  strE2K3WMIQuery = "winmgmts://" & strComputerName &_
    "/root/MicrosoftExchangeV2"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile(OutputFile, forWriting, True) ' opens output file for writing
objOutputFile.WriteLine "Display Name, Mailbox Size in KB, Store Name, Last Logon, No of Items" ' writes header names to output file
 
  ' Find each mailbox on the target server and report their
  ' Name , size in KB, store name
  Set mboxList = GetObject(strE2K3WMIQuery).InstancesOf("Exchange_Mailbox")
 
  For each mailbox in mboxList
Wscript.echo mailbox.MailboxDisplayName
        If mailbox.Size > "20000" Then
            strOutput = mailbox.MailboxDisplayName & "," & mailbox.Size & "," & mailbox.StoreName & "," & mailbox.LastLogonTime & "," & mailbox.TotalItems
                objOutputFile.WriteLine strOutput
            Else
      End if
Next
'END Script
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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!
Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
This video discusses moving either the default database or any database to a new volume.
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
Course of the Month15 days, 15 hours left to enroll

850 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