2014-12-16 4 views
0

Я пытаюсь получить наименьшее Exchange базы данных в моем Exchange 2010 сервер с использованием удаленного сеанса.Как получить размер базы данных 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();  
    } 

ответ

0

Я нашел решение В getMDB.Parameters.Add необходимо для параметра состояния, чтобы изменить значение с «нулевой», чтобы «истинный»

getMDB.Parameters.Add("Status", null); 
Смежные вопросы