Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

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



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
Avatar of mass2612
mass2612
Flag of Australia image

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
Avatar of bsharath

ASKER

No idea about scripting...
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
Avatar of William Elliott
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

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  
---------------------------
What version of Exchange are you using?
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
Avatar of Exchange_Admin
Exchange_Admin

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
ASKER CERTIFIED SOLUTION
Avatar of mass2612
mass2612
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial