2021/09/08 #切断されたメールボックスを探す

皆様おはようございます、

#猫でもできるPowerShell(備忘録)

#切断されたメールボックスを探す

<# 元ネタ

ネットワーク内の切断されたメールボックスExchange Server

https://docs.microsoft.com/ja-jp/exchange/recipients/disconnected-mailboxes/disconnected-mailboxes?view=exchserver-2019

#>

組織内の無効なメールボックスを識別するには、管理シェルで次Exchange実行します。

$dbs = Get-MailboxDatabase

$dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} |

where {$_.DisconnectReason -eq "Disabled"} |

Format-Table DisplayName,Database,DisconnectDate

※このコマンドが何故かエラーになり、自分の環境でさんざん調べる事に

結果、DisconnectReason プロパティで gettype() するとどうやら Int32型になる模様

(画面上ではどう見ても文字列表記だが・・)

という事で、whereのフィルタ部分は以下のような記述が正しいように思います

$dbs = Get-MailboxDatabase

$dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} |

where {$_.DisconnectReason -eq 2} |

Format-Table DisplayName,Database,DisconnectDate

いくつか数字を当てはめてみた所

-eq 2 だと "Disabled"

-eq 3 だと "SoftDeleted"  のメールボックスが抽出される事が判明しました

その他どのような数値が入ってくるやら

ではまた;