bsharath
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
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.Fi leSystemOb ject")
Set objOutputFile = objFSO.OpenTextFile(Output File, 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) .Instances Of("Exchan ge_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
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.Fi
Set objOutputFile = objFSO.OpenTextFile(Output
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)
For each mailbox in mboxList
If mailbox.Size >= 20000 Then
strOutput = mailbox.MailboxDisplayName
objOutputFile.WriteLine strOutput
Else
Next
'END Script
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=msExchExc hangeServe r);"
strAttrs = "name;"
strScope = "Subtree"
set objConn = CreateObject("ADODB.Connec tion")
objConn.Provider = "ADsDSOObject"
objConn.Open
'************************* ********** ********** ********** ********** *****
'Need to enable Paging in case there are more than 1000 objects returned
'************************* ********** ********** ********** ********** *****
Set objComm = CreateObject("ADODB.Comman d")
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.Fi leSystemOb ject")
Set outfile = fso.CreateTextFile("c:\out .txt", TRUE)
'************************* ********** ********** ********** ********** *****
'Write header line to file
'************************* ********** ********** ********** ********** *****
outfile.WriteLine "LegacyDN;" _
& "MailBoxGUID;" _
& "ServerName;" _
& "StorageGroupName;" _
& "StoreName;" _
& "AssocContentCount;" _
& "DateDiscoveredAbsentInDS; " _
& "DeletedMessageSizeExtende d;" _
& "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.DateDiscoveredAbsen tInDS
outfile.Write ";" & objMbx.DeletedMessageSizeE xtended
outfile.Write ";" & objMbx.LastLoggedOnUserAcc ount
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
' 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
' ------ END CONFIGURATION ---------
'*************************
'Set the ADO search criteria
'*************************
strBase = "<LDAP:// " & strConfigDN & ">;"
strFilter = "(objectcategory=msExchExc
strAttrs = "name;"
strScope = "Subtree"
set objConn = CreateObject("ADODB.Connec
objConn.Provider = "ADsDSOObject"
objConn.Open
'*************************
'Need to enable Paging in case there are more than 1000 objects returned
'*************************
Set objComm = CreateObject("ADODB.Comman
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.Fi
Set outfile = fso.CreateTextFile("c:\out
'*************************
'Write header line to file
'*************************
outfile.WriteLine "LegacyDN;" _
& "MailBoxGUID;" _
& "ServerName;" _
& "StorageGroupName;" _
& "StoreName;" _
& "AssocContentCount;" _
& "DateDiscoveredAbsentInDS;
& "DeletedMessageSizeExtende
& "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").
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.DateDiscoveredAbsen
outfile.Write ";" & objMbx.DeletedMessageSizeE
outfile.Write ";" & objMbx.LastLoggedOnUserAcc
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
ASKER
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
-------------------------- -
--------------------------
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
Open up exchange system manager, browse to your server, open up the mailbox resources, and export them to a TXT file
-red
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
I try to subscribe to the K.I.S.S. philosphy.
Russ
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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