我是PowerShell的新手,我编写了这个脚本来检查db的状态:
#if SWIGCSHARP
// C++
%typemap(ctype) boost::optional<int32_t> "void *"
%typemap(out) boost::optional<int32_t> %{
std::vector<int32_t> result_vec;
if (!!$1)
{
result_vec = std::vector<int32_t>(1, $1.get());
}
else
{
result_vec = std::vector<int32_t>();
}
$result = new std::vector< uint32_t >((const std::vector< uint32_t > &)result_vec);
%}
// C#
%typemap(imtype) boost::optional<int32_t> "global::System.IntPtr"
%typemap(cstype) boost::optional<int32_t> "int?"
%typemap(csout, excode=SWIGEXCODE) boost::optional<int32_t> {
SWIG_IntVector ret = new SWIG_IntVector($imcall, true);$excode
if (ret.Count > 1) {
throw new System.Exception("Return vector contains more then one element");
}
else if (ret.Count == 1) {
return ret[0];
}
else {
return null;
}
}
#endif //SWIGCSHARP
它运作良好。唯一的问题是如果我卸载了超过1个db,我会得到这样的东西:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
$null = Get-MailboxDatabaseCopyStatus | Where-Object {$_.status -match "Mounted" } -outvariable dbstatus
$null = $dbstatus.status
if (-not $dbstatus.status -eq "Mounted"){
Write-Host "OK"
}
Else {Write-Host $dbstatus.name status: $dbstatus.status}
我该如何解决这个问题?
答案 0 :(得分:0)
由于logs
是$dbstatus
个对象的集合,因此您需要在循环中迭代它以获取每个单独数据库的状态:< / p>
DatabaseCopyStatusEntry