By SiriusBCreated 18 Mar 2009
My Rating:
Vote
Rating:
Not Rated
Views:6480
Downloads:142
Source:

List Exchange Mailboxes by Server

Language:  VBScript

Compatibility

Windows XP Unknown Windows 2003 Yes
Windows 2000 Unknown Windows NT Unknown
Vista Unknown Windows 2008 Unknown
Description

This script list all the mailboxes of an Exchange Organization in separate text files, one text file for virtual server. The script also asks for each Exchange server found in your organization wether you want it to be listed or not. NOTE: The first part of the script is taken from (List Exchange Servers): http://www.wisesoft.co.uk/scripts/vbscript_list_exchange_servers.aspx

Code

Line Numbers: On  Off      Plain Text
set cn = createobject("ADODB.Connection")
set cmd = createobject("ADODB.Command")
set rs = createobject("ADODB.Recordset")

set objRoot = getobject("LDAP://RootDSE")
configurationNC = objRoot.Get("configurationnamingcontext")

cn.open "Provider=ADsDSOObject;"
cmd.activeconnection = cn

cmd.commandtext = "<LDAP://" & configurationNC & _
		  ">;(objectCategory=msExchExchangeServer);name;subtree"

set rs = cmd.execute

while rs.eof<>true and rs.bof<>true

'----------------------------------------------------
' Pregunta si queremos sacar el listado del Servidor
' que nos muestra el cuadro de dialogo o no
'----------------------------------------------------

iResposta = MsgBox("Listado Servidor: " & rs(0), 4,"Listado Buzones")
if iResposta = 6 then

' --------------------------------------------------
' Extraemos los datos de los buzones (WMI) y creamos 
' el fichero de texto con el nombre del servidor
' --------------------------------------------------

On Error Resume Next

Set FileSystem = WScript.CreateObject ("Scripting.FileSystemObject") 
Set OutPutFile = FileSystem.CreateTextFile ("Listado_" & rs(0) & ".txt", True) 


strComputer = rs(0)
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

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

OutPutFile.WriteLine "Associated content count" & vbTab & "Date discovered absent in directory service" & vbTab & "Delete messages size extended" & vbTab & "Last logged-on user account" & vbTab & "Last logoff time" & vbTab & "Last logon time" & vbTab & "Legacy distinguished name" & vbTab & "Mailbox display name" & vbTab & "Mailbox GUID" & vbTab & "Server name" & vbTab & "Size" & vbTab & "Storage group name" & vbTab & "Storage limit information" & vbTab & "Store name" & vbTab & "Total items"
For Each objItem in colItems
	OutPutFile.WriteLine objItem.AssocContentCount & vbTab & objItem.DateDiscoveredAbsentInDS & vbTab & objItem.DeletedMessageSizeExtended & vbTab & objItem.LastLoggedOnUserAccount & vbTab & Fecha(objItem.LastLogoffTime) & vbTab & Fecha(objItem.LastLogonTime) & vbTab & objItem.LegacyDN & vbTab & objItem.MailboxDisplayName & vbTab & objItem.MailboxGUID &  vbTab & objItem.ServerName & vbTab & objItem.Size & vbTab & objItem.StorageGroupName & vbTab & objItem.StorageLimitInfo & vbTab & objItem.StoreName & vbTab & objItem.TotalItems		
Next

' -----------------------------------
' Cerramos el fichero de texto creado
' -----------------------------------

OuputFile.Close

end if
rs.movenext
wend

cn.close

iFin = MsgBox ("         Finalizado", ,"Listado Buzones")

' -------------------------------------------------------
' Función para convertir la fecha de los objetos:
' DateDiscoveredAbsentInDS,LastLogonTime y LastLogoffTime
' -------------------------------------------------------

Function Fecha (Data)
	If IsNull (Data) Then
		Fecha=""
	Else
		Fecha=Mid(Data,7,2) & "/" & Mid(Data,5,2) & "/" & Left(Data,4) & " " & CInt(Mid(Data,9,2)) & ":" & Mid(Data,11,2)
	End If
End Function

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      
Be the first to post a comment!