Microsoft 365メッセージセンターをPowerShellで一括取得・管理する方法
Microsoft 365の管理者なら、メッセージセンターの通知をどう管理するかは悩みどころです。管理センターのUIで1件ずつ確認するのは非効率で、重要なMCを見落とすリスクがあります。
Graph APIとPowerShellを組み合わせることで、MCの一覧取得・フィルタリング・エクスポートを自動化できます。
必要なもの
Microsoft 365テナントの管理者権限
Microsoft Graph PowerShell SDK
サービスプリンシパル(アプリ権限での実行の場合)
基本的な取得コマンド
powershellConnect-MgGraph -Scopes "ServiceMessage.Read.All"
$messages = Get-MgServiceAnnouncementMessage -All
$messages | Select-Object Id, Title, StartDateTime, EndDateTime, Severity |
Sort-Object StartDateTime -Descending |
Export-Csv -Path "mc_list.csv" -Encoding UTF8 -NoTypeInformation
重要度でフィルタリングする
powershell$highPriority = $messages | Where-Object { $.Severity -eq "high" }
$highPriority | Select-Object Id, Title, StartDateTime | Format-Table
タグで絞り込む
MCにはタグ(planForChange・stayInformed等)が付いています。
powershell$planForChange = $messages | Where-Object {
$.Tags -contains "planForChange"
}
実運用での活用
私はこのスクリプトをベースに、MC番号・タイトル・影響度判定・対応期限をCSVで管理しています。月次でブログ記事にまとめる際の元データとして使っています。
詳しい活用方法や判断軸についてはrocomoco99.comで解説しています。
👉 https://rocomoco99.com