Function Get-DatabaseStatus
{
Param(
[String[]]$Server
)
$Server | ForEach-Object {
# Show some progress indicators
Write-Host "Starting Loop for $_"
Write-Host "Executing WMI Query"
$wmiServer = Get-Wmiobject Exchange_Server -Computer $_ `
-Namespace root\MicrosoftExchangeV2 #-ErrorAction SilentlyContinue
Write-Host "Creating CDOEXM Objects"
$cdoexmIExchangeServer = New-Object -com CDOEXM.ExchangeServer
$cdoexmIStorageGroup = New-Object -com CDOEXM.StorageGroup
$cdoexmIMailboxStoreDB = New-Object -com CDOEXM.MailboxStoreDB
Write-Host "Opening Exchange Server Data Source"
$cdoexmIExchangeServer.Datasource.Open($_)
Write-Host "Checking StorageGroups"
$cdoexmIExchangeServer.StorageGroups |
Where-Object { $_.IndexOf("CN=Recovery Storage Group") -ne 0 } |
ForEach-Object {
Write-Host "Opening Storage Group $_"
$cdoexmIStorageGroup.DataSource.Open(('LDAP://' + $_))
$cdoexmIStorageGroup.MailboxStoreDBs | ForEach-Object {
Write-Host "OPening Store $MailStore"
$cdoexmIMailboxStoreDB.DataSource.Open(('LDAP://' + $_))
$cdoexmIMailboxStoreDB | Select-Object Name,
@{n='Status';e={ If ($_.Status -eq 0) { "Mounted" } Else { "Dismounted" } }}
}
}
}
}
}
Get-DatabaseStatus "server1", "server2" | ConvertTo-Html
|