How to get Exchange 2010 database size c#

I'm trying to get smallest Exchange database in my Exchange 2010 server using remote session.
I successfully connect to my exchange server and get database with properties. Some of them with value, but Properties "DatabaseSize" with Null value for each of them.
Did some body be able to get database size value?
For me important to use URI to connect Exchange DAG.
Part of my code below:
static void Main(string[] args)
string exchangePowershellRPSURI = "http://my.domain/powershell?serializationLevel=Full";
PSCredential credentials = (PSCredential)null;
//Provides the connection information that is needed to connect to a remote runspace
// Prepare the connection
WSManConnectionInfo connInfo = new WSManConnectionInfo((new Uri(exchangePowershellRPSURI)),
"http://schemas.microsoft.com/powershell/Microsoft.Exchange", credentials);
connInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
connInfo.SkipCACheck = true;
connInfo.SkipCNCheck = true;
connInfo.SkipRevocationCheck = true;
// Create the runspace where the command will be executed
Runspace runspace = RunspaceFactory.CreateRunspace(connInfo);
// Add the command to the runspace's pipeline
runspace.Open();
//Represents the base functionality of a pipeline that can be used to invoke commands
Pipeline pipeline = runspace.CreatePipeline();
Command getMDB = new Command("Get-MailboxDatabase");
getMDB.Parameters.Add("Identity", "*");
getMDB.Parameters.Add("Status", null);
pipeline.Commands.Add(getMDB);
Collection<PSObject> select = pipeline.Invoke();
if (select.Count > 0)
foreach(PSObject obj in select)
var db = obj.Properties["DatabaseSize"].Value;
string name = obj.Properties["Name"].Value.ToString();
Console.WriteLine("Database Name: {0} Size: {1}", name, db);
else
Console.WriteLine("Failed to create email account");
runspace.Dispose();
Console.ReadLine();

I found solution of my problem by myself. I just changed in string
getMDB.Parameters.Add("Status", null);
"null" to "true" like this:
getMDB.Parameters.Add("Status", true);
Now everything work fine for me.

Similar Messages

  • How to get Exchange 2010 Product Keys from an existing installed servers

    hi All,
    we are facing some kind of critical issues. we had 3 MB servers . the two servers are in DAG all our productions DB's running in DAG. the DAG servers are crashed due to hardware issues. one server is acting as archival server. all servers are running exchange
    2010 sp3. 
    now we are trying to rebuild new servers to restore DB's. the new servers is prompting the product key to be entered. unfortunately we don't have product keys of exchange 2010. since we are gold partner we have partner network portal. when i tried to get
    the product key from portal am able to see only 2013 keys. we called up Microsoft and explained but no use. they said we have to use exchange 2013. but we cant simply go ahead and migrate. 
    but the only option is we have exchange 2010 installed servers they all act as CAS/HUB server with the same licence. please let me know how do i retrieve exchange 2010 product keys from an existing servers. Please advise me its very critical.
    can we get the product keys through some kind of scripts?
    Thanks, Venkatesh. &quot;Hardwork Never Fails&quot;

    Hi,
    For this issue, I recommend you contact Microsoft customer service to consult this question. Thanks for your understanding.
    Best regards,
    Belinda
    Belinda Ma
    TechNet Community Support

  • Replay only particular logs (before a certain date) to restored Exchange 2010 database?

    Hello,
    I'm doing Exchange 2010 database full backup using windows server backup (windows 2008 R2) every weekend. I have a Mac user which Mac Outlook 2011 which somehow managed to corrupt his mailbox. I.e. on Wednesday many messages and contacts disappeared (all
    contact gone) after his Outlook told his something about "corrupted database". I'm not sure what Mac Outlook did, but fact is that his mailbox has zero contacts and many inbox message are gone. Hard deleted items don't contain lost messages. 
    So I have DB backup from weekend before and weekend after. No circular logging, so all logs in place.
    Is there a way how I can restore his mailbox back to the point in time? I want to restore his mailbox how it was on Wednesday morning. For it looks obvious that since I have log files from Monday to Friday, it should be possible to replay logs until certain
    time. 
    I tried to did thick trick by removing Friday and Thursday logs and doing soft recovery, but got Operation terminated with error -543 (JET_errRequiredLogFilesMissing, The required log files for recovery is missing.) They indeed missing:
             dbtime: 2221857861 (0x846edc45)
              State: Dirty Shutdown
       Log Required: 2895446-2895464 (0x2c2e56-0x2c2e68)
      Log Committed: 0-2895465 (0x0-0x2c2e69)
     Log Recovering: 2838005 (0x2b4df5)
    Log required are logs from they day of backup, so they are really missed in that case, but that's what I want - restore DB with less/older logs to get back in time, when mailbox was not corrupted.
    Is that possible? 
    Thanks

    ok so the problem is you have the dreaded  -1018 error and this is a very serious issue. -1018 is not a good deal at all, in short your DB has corruption within it
    and it is usually caused by a hardware or firmware related issue. Most of the time these occur somewhere within the storage subsystem, i.e. firmware upgrade or lack of firmware upgrade, Controller issue, cabling, disk, disk arrays, etc, however they can
    also be caused by memory upgrades or failures, Motherboard issues etc.   The -1018 tells you the DB is already damaged and if you see these its very bad and needs to be addressed ASAP else the DB's are sure to fail and the more stress you put on
    them the faster the chance of failure, i.e. database backups, defrag;s and repairs etc are not recommended at all until you solve the hardware issue.  So here is what I would recommend:
    A: Lets try to ensure the box is stable and whatever caused the DB to get the -1018's is solved before we do anything else.
    General Review:  Whats changed recently?  i.e. any hardware, memory, motherboard, any firmware updates on anything at all?
    Event Log Review: Look at your Application Log, how long have these 1018's been occurring?   Look at your System event log for errors and pay close attention to any errors regarding disk, memory or MB and report back
    Protect: I would dismount the database & copy it and any others off to a secure, safe drive that is NOT connected to this system
    Action:  Depending on what you find in your review there are really two options
         i: If you had a recent change that is easily identifiable you may be able to correct it and then we can look at finding a clean copy of the EDB and rolling up the logs OR we opt to repair the DB you have
         ii: if you cannot find the issue in short order then I would suggest that you build a new Exchange Server on new hardware and migrate your mailboxes immediately.
    B: Once you have addressed the -1018 issue then;
    1. We need to find a database from your backups that does NOT have the -1018 result code when attempting a rollup.
    2. Once you have a non -1018 result you can then grab a fresh copy of the EDB along with all logs from that point forward and make a consistent DB via rollup up to the 18th as desired.
    3. If you cannot find a good copy of the EDB then you are stuck with the latest data you have and should either move all mailboxes to a new EDB on that server but ONLY IF the source of the -1018 is found and resolved, else you will just be making thing s
    worse.  IF you CANNOT resolve the issue that causes the -1018 then build a brand new server and move all users over to it ASAP, else you are headed for a major failure on all users.
    Search, Recover, & Extract Mailboxes, Folders, & Email Items from Offline Exchange Mailbox and Public Folder EDB's and Live Exchange Servers or Import/Migrate direct from Offline EDB to Any Production Exchange Server, even cross version i.e. 2003 -->
    2007 --> 2010 --> 2013 with Lucid8's
    DigiScope

  • Script for unmounting/deframenting exchange 2010 database

    hi all,
    i need a script to unmount exchange 2010 database, defrag it and mount it again.
    thanks for any comment you may add...

    Tried the above commands... works like a charm, but with the following modifications:
    1. Delete trash and recoverable items from all mailboxes, run repeatedly
    The command using is
    Search-Mailbox -Identity "mailbox.name" -SearchDumpsterOnly -DeleteContent
    1A. Determining Free Space in Mailbox Database
    The command using is
    Get-MailboxDatabase -Status | ft name,Availablenewmailboxspace,Databasesize
    2.Calculate the disk space to perform the defrag, the formula is
    (Databasesize-Availablenewmailboxspace)*1.1
    3.Dismount the mailbox database
    In EMS, go to the folder contain the database file then use the command
    Dismount-Database <DatabaseName>
    3A.Copy mailbox database (edb and all related log files) to another location
    In EMS, go to the folder contain the database file then use the command
    4.Defrag the edb file (eseutil will recreate a temp edb and rename to the new edb after successful complete it will delete the old edb file. If anything goes wrong, it will revert back to the old edb as in the /d)
    eseutil /d <file.edb>
    5.Mount again
    Mount-Database <DatabaseName>
    You are advised to purge (step 1) all mailboxes before eseutil or move mailbox, otherwise it will just carry all the sh!t over to the new mailbox anyway. I gave up trying to tally the total mailbox space used, the whitespace avail and the edb file size already.
    For example, not sure why there is such a disparity where by I have 30 2GB mailboxe est. at 60GB used, whitespace after mailbox move/eseutil at 95GB, the edb size is 106GB. This is where my older exchange 2003 edb files wins hands down. Better budget more
    storage for edb files! I am considering whether it's even worth migrating all to exchange 2010 altogether! The edb files are so damn space hungry even with 3 day retention and 6 day delete with 24/7 maintenance ticked. Exchange 2010 edb beast simply cannot
    be tamed.
    Personally I find in EMC to online move mailbox faster and more reliable overnight. Furthermore, you can simply create a new database, sort all mailboxes by database, select all of them, follow the wizard to move them all at once, the system simply queues
    them to move and complete. Overnight moving is the best, all will be done the next day.

  • How to get to know the size of the biggest file in ContentServer

    Dear colleagues!
    Does anybody knows how to get to know the size of the biggest file in the ContentServer?
    Vladimir
    Edited by: Vladimir Pavlovsky on Mar 2, 2010 11:11 AM

    Vladimir Pavlovsky wrote:>
    > Dear colleagues!
    > Does anybody knows how to get to know the size of the biggest file in the ContentServer?
    Hi Vladimir,
    I assume you want to know the size of the biggest file stored in the content server don't you?
    This information is available through the content server API layer only - so better open this question in the knowlegde management forum.
    regards,
    Lars

  • Exchange 2013 Database Size didn't reduction after user move another DB.

    Hi, I have two Exchange Server Ex01, Ex02 and two database DB1 and DB2. Already we move few user DB1 to DB2 but DB1 database size didn't reduction after move user. 
    Md. Ramin Hossain

    Hi ,
    If you delete or move a mailbox from a database will not create a free space on that database.Instead a white-space will be created on that database during the online defragmentation and that will not make any changes on the physical size of the database
    .Then that white-space will be used when a new mailbox is created on that same database.
    In case if you wanted to convert those white space to free space then you need to do an offline defragmentaion and that will make the physical change in the size of the database
    Note : For offline defragmentation we should have the database to be in a dismounted state.
    Command for offline defragmentation : 
    eseutil /d "path of the edb file"
    But my suggestion would be to move the mailboxes to the newly created database instead of doing the offline defragmentation to attain the free space .Because it would take too much of time for the large databases to get completed.
    Reference link for offline defragmentation : 
    http://exchangeserverpro.com/defrag-exchange-2010-mailbox-database/
    Command to see the white space on the mailbox database :
    ESEUTIL /MS "path of the edb file"
    To execute the above we need the database to be in a dismounted state.
    Reference Link : 
    https://social.technet.microsoft.com/Forums/office/en-US/4059c686-7c02-483b-9b15-891ca55295fe/running-the-eseutil-command-on-each-exchange-database-to-verify-database-whitespace?forum=exchangesvrgeneral
    Please reply me if anything is unclear.
    Thanks & Regards S.Nithyanandham

  • Exchange 2010 Database Corrupted Every Several Months,I/O Disk,Event 203

    Hi
    I am Running Exchange 2010 on Vm Machine,
    Machine Profile:
    16Gb Ram,4 Cpu,200 Gb Database,200 users.
    Every Several months I Need To Migrate The Mailboxes To New Database,
    The Old Database(After the mailboxes migration Process) always Get Error event 203,
    Its Cyclic error That Occured every Serval Months To New Database.
    I Am Backup Successfully The Database With Full Vss Every Day until the database get corrupted!,
    The Biggest mailbox Is 10 Gb.
    I Noticed That The Error Occured When The Store process Was On 17,000,000 kb/sec Persistent.
    My Exchange Storage Is On Virtual San Hp Vsa.
    The Strange Thing is I Have physical exchange 2010 servers in different company who serves 200 users as well,
    has 200 gb database ,Less Ram Memory from my vm,
    but The Big Difference is i didnt have any issues with the physical server like i have with the vm.
    how can i be sure if my storage(virtual san,hp vsa) have poor issue when the exchange need to
    work on high I/O ?
    I Got The Event 203 When The Store Process Was On 17,000,000? is it normal?
    Is My Storage Cause To My New Database Get Corrupted Because It Has Poor Performance?
    thx
    kobi

    Thank You
    How Can I Monitor/Test My Virtual San Environment To Ensure Its Function When Hosting Exchange 2010?
    Can Jetstress 2010 Can Supply Me Answers To My Cyclic Problem?
    Is there A Tool Or Configuration To Achieve Store Process On 17,000,000 b/Sec?

  • Exchange 2010 - Database issues

    Good morning everyone!
    I have an exchange database problem.  It was first caught when implementing exchange backups with Acronis backup software.
    (EXCHANGE 2010 v 14.01.0218.013)
    So the backups fail one night and succeed the next.  But each time it fails we get 4 errors (Consistency related).  Also the database size is growing rapidly.  Here are the errors:
    Then a couple more:
    EVENT ID 9782
    Exchange VSS Writer (instance b1bfbf43-9594-4cee-980f-50d84b0ee4eb:76) has completed the backup of database 'xxxxxxxxx' with errors. The backup did not complete successfully, and no log files were truncated for this database.
    Then finally:
    EVENT ID 2007
    Information Store (2136) Shadow copy instance 76 aborted. 
    For more information, click http://www.microsoft.com/contentredirect.asp.
    EDIT:
    SO my DB is not growing because the issue...I had forgotten that we enabled LEGAL HOLD.  But my backups fail / succeed / fail / succeed.
    Any ideas on this?
    Kevin

    Hi,
    Please use Windows Server backup to backup the Exchange database to check result.
    If Windows Server backup works well, I recommend you contact the third party support to confirm this issue.
    If the issue persists, please check whether your database is dirty shutdown. If it's dirty, please bring to clean state and backup agian to check result.
    Best regards,
    Belinda Ma
    TechNet Community Support

  • Rename existing Exchange 2010 database in DAG

    Hello,
    I want to rename one existing database on our exchange 2010 server. This database is in DAG and hosting around 1000 users. So not possible to create a new mailbox database and move.
    How can I rename the database?
    After renaming it, what will happen to the Copy database on another server as it is in DAG.
    Thanks,
    Mihir

    Appreciate your response, Andy.
    To clear my doubt,
    If I am ok to reseed the passive copy, then I can follow below steps, Correct?
    --> Remove Passive copy
    --> Remove Database files and Log files on this passive server manually
    And
    "1. Then will a New database with this new name be created?"
    --> On Move database, I will mention same location, but just
    rename .edb file. So a exact copy of new database with this new name will be created. Correct?
    --> And then I can delete the old named .edb, Correct?
    Thanks.

  • Exchange 2010 database help after clean install of exchange 2010

    Long story short. Had exchange 2010 issues. My exchange store would not open and I could not mount database. Copied v14 folder over to another folder. Removed exchange from AD, recreated my windows 2008 r2 virtual machine, Installed completely new exchange.
    It came up with new mailbox offline, which i left that way. I copied my flat files into the newly created v14 folder. When I open exchange, I see an unmounted copy of my old database. However, I am unable to do anything with it. Esutil said it was a clean
    shutdown. I am looking for the steps I need to take to get my old database back online as it has everyone's info. So exchange see's a copy of my old database, but nothing else. Any help would be appreciated. Thanks in advance.
    John

    Thanks for the response Willard,
    Your correct, I have placed myself in a Jam. the .edb file is in a clean state. I copied the whole directory over to a mapped drive. I am currently working the problem 2 ways. I have created a recoveryDB, but when I try to perform a New-MailboxRestore request
    it fails. When i do a get statistics I can see all email in the recoveryDB, but only a system file mailbox in the new database i created, none of my users. I have also tried the database portability. I can check and confirm the old database, but at the last
    step I am supposed to Get Mailbox -Database "old database", it fails to find the old database. So I am unable to run Get-Mailbox -Database "old Database" | Set-Mailbox -Database "New Database". I have set the new database to be
    overwritten. The problem arises when i try to get-mailbox -Database (old database)=   it says it cannot find database. Since I performed a clean install the old database is not in Active directory. When I open the path to the new database it is pointing
    at the .edb in the folder I created using the steps at www.exchangerecover.com/blog/2010/move-a-mailbox-database-using-database-portability.html
    Now that I totally screwed it up, I can start from the beginning if necessary. I am just hoping I do not lose the data. I would appreciate a push in the right direction. I am currently trying to touch base with an exchange admin at the local university.
    We have played phone tag so far. Microsoft support is my next option.
    John

  • Exchange 2010 Databases move alert via email

    Hello Team,
    We are in Exchange 2010 SP3 environment with 2 copy DAG and don't have any SCOM Server for monitoring purpose. Please help to get script which helps to alert us via email whenever any database moved from one server to another server or any database in failed
    status.

    Hi   Jha
    Thank you for your question.
    You can refer to the following link and modify some code to type the correct email address by which someone was reminded, but it just reminded when your database fail .
    http://ammarhasayen.com/2013/10/01/get-alert-email-when-exchange-database-is-failed-orand-not-mounted-on-the-preferred-server-activation-preference/
    If this script cannot meet your requirement and you to get some alert when database moved, you can post your requirement on Exchange Development Forum by the following link:
    https://social.technet.microsoft.com/Forums/en-US/home?forum=exchangesvrdevelopment&filter=alltypes&sort=lastpostdesc
    If there are any questions, please let me know.
    Best Regard,
    Jim

  • How to integrate exchange 2010 in oim 9.1.0.2

    Hi all,
    Present my company is running with the OIM version 9.1.0.2.
    we are running with the exchange 2003.
    scenario is
    we need to upgrade exchange 2003 to exchange 2010.
    could you please let me know the connector version for the exchange 2010 in oim 9.1.0.2.
    Please suggest me the procedure for achieve this.
    Thnaks,
    -Valli

    Hi srini,
    thanks for your reply,
    Actually we integrated with 2003 exchange server, and we need a new integration with exchange server 2010.
    we don't want to disturb 2003.
    We are confusing with connector versions and how to perform those things.
    Thnaks,
    Valli

  • How to find out the database-size

    Hello,
    how can I find out the size of the database.
    I created the user as below. I defined the size of the database to 2MB. Now I want to know how much is the size of the database.
    CREATE USER oemer
    IDENTIFIED BY ...
    DEFAULT TABLESPACE system
    QUOTA 2M ON system;

    Actually, since Omer is a veteran poster to the Forms and Reports forums, I doubt that. I think he is making a much more interesting journey: from front-end to back-end.
    I'll be a bit more helpful this morning.
    Databases are ways of organising disk space to store data. Fundamentally they consist of OS files, data files. The RDBMS handles by grouping them into tablespaces. When we build tables we assign them to a tablespace.
    So, the size of the database is the sum of its datafiles. Of course, some tablespaces are used for sorting and holding undo information, so the size of the database for the purposes of persisting data is:
    SELECT count(x.tablespace_name) AS total_TS, sum(x.MB) AS total_mb, sum(x.free_mb) AS total_free_mb
    FROM   ( SELECT t.tablespace_name, sum(d.bytes)/1048576 AS mb, sum(f.bytes)/1048576 AS free_mb
             FROM   dba_free_space f, dba_data_files d, dba_tablespaces t
             WHERE  t.contents = 'PERMANENT'
             AND    d.tablespace_name = t.tablespace_name
             AND    d.file_id = f.file_id
             GROUP  BY t.tablespace_name ) x
    /The SYSTEM tablespace is special. It is used by Oracle to hold the data dictionary, the definitions of all the objects in the database. It should not be used for storing application objects (it affects the performance, apatrt from anything else). That is why we must not use it as a default tablespace.
    CREATE USER oemer
    IDENTIFIED BY ...
    DEFAULT TABLESPACE ts_users
    QUOTA 2M ON ts_users; Cheers, APC

  • How to get the current Mailbox size

    Hi,
    Does anyone know how to get the current size of Mailbox and Archive by using GW api?

    Originally Posted by NanLau
    Hi,
    Does anyone know how to get the current size of Mailbox and Archive by using GW api?
    Can anyone answer this? Thanks.

  • How to get data from database to JComboBox

    hi
    i am trying to get data which is in database. here the problem is i am getting only one row in the JcomboBox
    i want all data just like list. i dont know how to get that . below is the code plz any one help me....
    import javax.swing.*;
    import javax.swing.JList.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.String.*;
    import java.lang.Integer.*;
    import java.sql.*;
    public class customer_code extends JFrame implements ActionListener
    Container c=getContentPane();
    JLabel customer_code=new JLabel("Customer Code and Name");
    customer_code()
    super("Customer Details");
    setSize(300,250);
    setVisible(true);
    setLayout(null);
    setLocation(430,310);
    Font f=new Font("SansSerif",1,16);
    Font f1=new Font("SansSerif",0,14);
    customer_code.setBounds(10,20,250,30);
    add(customer_code);
    customer_code.setFont(f);
    ResultSet rs=null;
    String j=null,k=null;
    try
    System.out.println("MySQL Connect Example.");
    Statement st=null;
    Connection con=null;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:project","vikky","vishu");
    System.out.println("Connected to the database");
    st=con.createStatement();
    rs=st.executeQuery(" select code as c,Customer_name as n from customer_details ");
    while(rs.next())
    j=rs.getString("c");
    k=rs.getString("n");
    System.out.println(j);
    System.out.println(k);
    String[] names = new String[] {j,k};
    JComboBox comboBox = new JComboBox(names);
    add(comboBox);
    comboBox.setBounds(25,60,250,50);
    comboBox.setFont(f);
    comboBox.addActionListener(this);
    comboBox.setMaximumRowCount(10);
    con.close();
    System.out.println("Disconnected from database");
    catch (Exception e)
    e.printStackTrace();
    public void actionPerformed(ActionEvent event)
    if ("comboBoxChanged".equals(event.getActionCommand()))
    System.out.println("User has selected an item from the combo box.");
    JComboBox comboBox = (JComboBox) event.getSource();
    if(comboBox.getSelectedItem().equals("None"))
    public static void main(String agr[])
    customer_code cd=new customer_code();
    }

    r035198x wrote:
    Also separate that database code from interface display code.
    You should never access the database on the EDT.
    See [Doing Swing Right|http://bytes.com/topic/java/insights/853297-doing-swing-right] for more details.
    Yes! By the time you are working with Swing and JDBC you should already know how to structure code. If not, then you are not ready for these topics and you've jumped the gun.

Maybe you are looking for