演練值如何代入。以 LAB_ 開頭的代號代表合成測試值。命令或設定中的代號,請先一致代換成隔離測試環境的值。前綴代號依欄位規格填入前綴長度,需要位址型別的欄位請填入合法的合成位址。代換後再驗證設定語法與預期結果。
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 $LabAdminUpn -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 -Identity $LabMailbox -Properties RecipientTypeDetails,EmailAddresses | Select-Object RecipientTypeDetails,EmailAddresses依核准範圍選欄位。正式分享前移除地址;缺欄位時查 Properties 或 PropertySets。
搜尋所有收件者Exchange Online PowerShell
Get-EXORecipient -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress,RecipientType可找 mailbox、group、contact、mail user 地址衝突。
查 ProxyAddressesExchange Online PowerShell
Get-EXOMailbox user@LAB_DNS_NAME_5 -Properties EmailAddresses | Select-Object -ExpandProperty EmailAddresses大寫 SMTP: 表示 primary address。
查看 Mailbox PermissionExchange Online PowerShell
Get-EXOMailboxPermission user@LAB_DNS_NAME_5 | Where-Object IsInherited -eq $falseFullAccess 和 SendAs 是不同權限。
查看 SendAs 權限Exchange Online PowerShell
Get-RecipientPermission user@LAB_DNS_NAME_5 | 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 含公司帳號資料,要限制存取與保存期限。
驗收與排錯
先確認租戶,再查一個合成收件者
比對 Get-ConnectionInformation 的連線、所屬租戶與角色。用已定義的 $LabMailbox 查看收件者類別、FullAccess、SendAs、SendOnBehalf 和 forwarding。這些是分開的權限與狀態。
若角色不足,只調整實際要驗收的最小範圍;離開後斷開該工作階段。完成權限變更以新工作階段實測允許、拒絕和正常寄件。
常見錯誤
- 使用 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,依當版文件與模組支援。