我在 C# 中包装 ExchangeManagementShell Cmdlet,以编程方式执行 cmdlet(请参阅 __http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/155504b3-ffe3-4bdf-887a-1e61842a8697)
我知道邮箱数据库的“数据库副本”属性包含副本。但我不确定如何解析 deserilzied databasecopies 数据以获取属性。
请看下面的代码片段。我基本上是在解析 Get-MailboxDatabase cmdlet 结果以获取我们感兴趣的属性。不知道如何从中获取 DatabaseCopies。
foreach (PSObject cmdletResults in this.Execute("Get-MailboxDatabase"))
{
MailboxDatabase mdb = new MailboxDatabase();
mdb.ExchangeApplicationSystemGlobalId = this.ExchangeApplicationSystem.GlobalId;
mdb.Name = cmdletResults.Properties["Name"].Value.ToString();
mdb.MountedOnServer = cmdletResults.Properties["Server"].Value.ConvertToString();
mdb.EdbFilePath = cmdletResults.Properties["EdbFilePath"].Value.ConvertToString();
mdb.LogFolderPath = cmdletResults.Properties["LogFolderPath"].Value.ConvertToString();
mdb.LogFilePrefix = cmdletResults.Properties["LogFilePrefix"].Value.ConvertToString();
mdb.Guid = cmdletResults.Properties["Guid"].Value.ToString();
string mt = cmdletResults.Properties["MasterType"].Value.ConvertToString();
if (!string.IsNullOrEmpty(mt))
{
mdb.MasterType = mt.ToEnum(MasterType.Unknown);
}
mdb.MasterServerOrAvailabilityGroup = cmdletResults.Properties["MasterServerOrAvailabilityGroup"].Value.ConvertToString();
PSObject pso = cmdletResults.Properties["Servers"].Value as PSObject;
if (null != pso
&& null != pso.BaseObject)
{
ArrayList servers = pso.BaseObject as ArrayList;
if (null != servers)
{
mdb.Servers = servers.ToArray().Where(server => null != server)
.Select(server => server.ToString())
.ToArray();
}
}
}