NeilA Posted May 10, 2007 Share Posted May 10, 2007 Does anyone have a script that will collect one or more users mailbox size from an Exchange server. I can do this via a VBS script but can't get it to work using AutoIt. Link to comment Share on other sites More sharing options...
sandman Posted May 10, 2007 Share Posted May 10, 2007 Could we see the VB code? That might help. [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
NeilA Posted May 16, 2007 Author Share Posted May 16, 2007 VBS Script is: On Error Resume Next Dim cComputerName Const cWMINameSpace = "root/MicrosoftExchangeV2" 'The rest of the script will fetch mailbox sizes for our server. 'Mailbox sizes are in Kilobytes. Const cWMIInstance = "Exchange_Mailbox" Dim strWinMgmts ' Connection string for WMI Dim objWMIExchange ' Exchange Namespace WMI object Dim listExchange_Mailboxs ' ExchangeLogons collection Dim objExchange_Mailbox ' A single ExchangeLogon WMI object Dim objFileSystem, objOutputFile Dim strOutputFile ' generate a filename base on the script name strOutputFile = "mailboxsizes.txt" Set objFileSystem = CreateObject("Scripting.fileSystemObject") Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE) WScript.Echo "Running" Mailsize("SERVER1") Mailsize("SERVER2") Mailsize("SERVER3") Mailsize("SERVER4") WScript.Echo "Finished" objOutputFile.Close Set objFileSystem = Nothing Sub Mailsize(cComputerName) ' Create the object string, indicating WMI (winmgmts), using the ' current user credentials (impersonationLevel=impersonate), ' on the computer specified in the constant cComputerName, and ' using the CIM namespace for the Exchange provider. strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& cComputerName&"/"&cWMINameSpace Set objWMIExchange = GetObject(strWinMgmts) ' Verify we were able to correctly set the object. If Err.Number <> 0 Then WScript.Echo "ERROR: Unable to connect to the WMI namespace." Else ' ' The Resources that currently exist appear as a list of ' Exchange_Mailbox instances in the Exchange namespace. Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance) ' ' Were any Exchange_Mailbox Instances returned? If (listExchange_Mailboxs.count > 0) Then ' If yes, Iterate through the list of Exchange_Mailbox objects. For Each objExchange_Mailbox in listExchange_Mailboxs ' ' Display the value of the Size property. objOutputFile.WriteLine objExchange_Mailbox.MailboxDisplayName & "|" & objExchange_Mailbox.Size & "|" & cComputerName Next Else ' If no Exchange_Mailbox instances were returned, display that fact. WScript.Echo "WARNING: No Exchange_Mailbox instances were returned." End If End If End Sub Link to comment Share on other sites More sharing options...
ptrex Posted May 16, 2007 Share Posted May 16, 2007 @NeilA Maybe this can be of any use ; This code lists the size of all mailboxes on the selected server. ; ------ SCRIPT CONFIGURATION ------ $strComputerName = "<serverName>" ; e.g. "batman" ; ------ END CONFIGURATION --------- $strE2K3WMIQuery = "winmgmts://" & $strComputerName & "/root/MicrosoftExchangeV2" ; Find each $mailbox on the target server and report their ; item counts and sizes $mboxList = ObjGet($strE2K3WMIQuery) $mbox = $mboxList.InstancesOf("Exchange_Mailbox") For $mailbox in $mbox $strOutput = "" $strOutput = "Mailbox: " & $mailbox.MailboxDisplayName & @CRLF $strOutput = $strOutput & " " & $mailbox.Size & "KB in " & $mailbox.TotalItems & _ " items" & @CRLF ConsoleWrite ($strOutput & @CRLF) Next Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
NeilA Posted May 16, 2007 Author Share Posted May 16, 2007 ptrex This works perfectly, thanks very much. I can stop banging my head against that wall now. NeilA Link to comment Share on other sites More sharing options...
ptrex Posted May 16, 2007 Share Posted May 16, 2007 (edited) @NeilA Glad to see it works. I have got +500 scritp lying around translated from Vbs to AU3. All Scipts ready to use for a Business environment, like Active Directory, Server 2003, Exchange, Etc. But I am not sure if I am willing to share them all for free. Regards ptrex Edited May 16, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now