Как получить размер базы данных Exchange 2010

Я пытаюсь получить наименьшую базу данных Exchange на своем сервере Exchange 2010, используя удаленный сеанс.

Я успешно подключаюсь к своему серверу обмена и получаю базу данных со свойствами. Некоторые из них со значением, но свойства DatabaseSize со значением Null.

Кто-то смог получить значение размера базы данных? Часть моего кода ниже:

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();     
    }

person user3824508    schedule 16.12.2014    source источник


Ответы (1)


Я нашел решение. В getMDB.Parameters.Add необходимо, чтобы параметр Status изменил значение с «null» на «true».

getMDB.Parameters.Add("Status", null);
person user3824508    schedule 16.01.2015