Exchange Online 管理先從唯讀盤點開始。Get-EXO* cmdlet 適合大量查詢;實際新增 alias、改權限或變更 mail flow 前,先縮到單一測試物件並保留原值。
模組與連線
查看模組版本PowerShell
Get-InstalledModule ExchangeOnlineManagement -ErrorAction SilentlyContinue沒有結果才需要安裝。
安裝目前使用者模組PowerShell
Install-Module ExchangeOnlineManagement -Scope CurrentUser企業環境先確認 PSGallery、簽章與版本控管。
更新模組PowerShell
Update-Module ExchangeOnlineManagement自動化主機不要未測試就升版。
互動式連線PowerShell
Connect-ExchangeOnline -UserPrincipalName [email protected] -ShowBanner:$false使用具名管理帳號與 MFA。
查看目前連線PowerShell
Get-ConnectionInformation確認 UserPrincipalName、State、TokenStatus 與 ConnectionUri。
登出並清除 sessionPowerShell
Disconnect-ExchangeOnline -Confirm:$false腳本結束一定登出,避免殘留 session。
Mailbox 與收件者
列出信箱摘要Exchange Online PowerShell
Get-EXOMailbox -ResultSize Unlimited -Properties DisplayName,PrimarySmtpAddress,RecipientTypeDetails | Select-Object DisplayName,PrimarySmtpAddress,RecipientTypeDetails大量 tenant 可分批與縮小 Properties。
查單一信箱Exchange Online PowerShell
Get-EXOMailbox [email protected] -Properties *輸出前先挑需要欄位,避免洩漏不必要資訊。
搜尋所有收件者Exchange Online PowerShell
Get-EXORecipient -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress,RecipientType可找 mailbox、group、contact、mail user 地址衝突。
查 ProxyAddressesExchange Online PowerShell
Get-EXOMailbox [email protected] -Properties EmailAddresses | Select-Object -ExpandProperty EmailAddresses大寫 SMTP: 表示 primary address。
查看 Mailbox PermissionExchange Online PowerShell
Get-EXOMailboxPermission [email protected] | Where-Object IsInherited -eq $falseFullAccess 和 SendAs 是不同權限。
查看 SendAs 權限Exchange Online PowerShell
Get-RecipientPermission [email protected] | Where-Object Trustee -ne 'NT AUTHORITY\SELF'SendOnBehalf 另看 GrantSendOnBehalfTo。
查看 mailbox forwardingExchange Online PowerShell
Get-EXOMailbox -ResultSize Unlimited -Properties ForwardingAddress,ForwardingSmtpAddress,DeliverToMailboxAndForward | Where-Object {$_.ForwardingAddress -or $_.ForwardingSmtpAddress}外部自動轉寄需符合資安與 outbound spam policy。
群組、網域與組織設定
列出 Distribution GroupExchange Online PowerShell
Get-DistributionGroup -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress,GroupTypeMicrosoft 365 Group 另用 Get-UnifiedGroup。
查看群組成員Exchange Online PowerShell
Get-DistributionGroupMember -Identity 'All-Staff' -ResultSize UnlimitedDynamic Distribution Group 沒有靜態 member 清單。
列出 Microsoft 365 GroupsExchange Online PowerShell
Get-UnifiedGroup -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress,AccessType同時確認 owner 與外部寄件設定。
查看 Accepted DomainsExchange Online PowerShell
Get-AcceptedDomain | Format-Table Name,DomainName,DomainType,DefaultAuthoritative 與 InternalRelay 的 routing 行為不同。
查看 Inbound ConnectorsExchange Online PowerShell
Get-InboundConnector | Format-List Name,Enabled,ConnectorType,SenderDomains,SenderIPAddresses,RequireTlsIP、certificate 與 sender domain 必須和實際來源一致。
查看 Outbound ConnectorsExchange Online PowerShell
Get-OutboundConnector | Format-List Name,Enabled,ConnectorType,RecipientDomains,SmartHosts,TlsSettings確認 smart host 與 TLS 要求。
列出 Mail Flow RulesExchange Online PowerShell
Get-TransportRule | Sort-Object Priority | Select-Object Name,State,Mode,Priority先查 audit/test mode,再看是否有 stop processing。
查看組織 mail flow 設定Exchange Online PowerShell
Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled,ExternalPostmasterAddress,MaxReceiveSize,MaxSendSize個別 mailbox 或 policy 仍可能覆蓋部分設定。
匯出信箱盤點Exchange Online PowerShell
Get-EXOMailbox -ResultSize Unlimited -Properties DisplayName,PrimarySmtpAddress,RecipientTypeDetails | Select-Object DisplayName,PrimarySmtpAddress,RecipientTypeDetails | Export-Csv .\exo-mailboxes.csv -NoTypeInformation -Encoding utf8CSV 含公司帳號資料,要限制存取與保存期限。
怎麼確認有做對
- 每次連線確認 tenant 與管理帳號,結束後 Disconnect。
- 變更前後用相同 Get 指令匯出並比對。
- 用實際寄送、委派登入與群組收件驗證,不只看 cmdlet 成功。
常見錯誤
- 使用 Global Admin 跑所有日常查詢。
- 把舊 Remote PowerShell session 範例和新版 REST-backed cmdlet 混用。
- 只查 FullAccess,漏掉 SendAs、SendOnBehalf 與 forwarding。
- 匯出全 tenant 資料後丟在公開分享資料夾。
常見問題
Connect-ExchangeOnline 要關掉 MFA 嗎?
不需要。互動管理應保留 MFA;無人值守腳本改用 app-only certificate 或 managed identity,不要退回帳密硬寫。
Get-Mailbox 和 Get-EXOMailbox 要用哪個?
Exchange Online 大量查詢通常優先 Get-EXOMailbox 並明確指定 Properties;特定舊參數仍可能要 Get-Mailbox,依當版文件與模組支援。
延伸閱讀
版本與官方文件
參數會隨工具版本與作業系統實作改變。正式環境先用 --help、-h 或系統內建說明確認,再以當版官方文件為準。
常見問題
Connect-ExchangeOnline 要關掉 MFA 嗎?
不需要。互動管理應保留 MFA;無人值守腳本改用 app-only certificate 或 managed identity,不要退回帳密硬寫。
Get-Mailbox 和 Get-EXOMailbox 要用哪個?
Exchange Online 大量查詢通常優先 Get-EXOMailbox 並明確指定 Properties;特定舊參數仍可能要 Get-Mailbox,依當版文件與模組支援。