在Exchange Online的管理中,對於郵箱的管理基本會充斥著大多數的工作時間。接下來將體驗使用Exchange Online PowerShell V2獲取郵箱相關信息。
一、Get-EXOMailbox命令
在Exchange Online PowerShell V2模塊中獲取郵箱對象和對應對象的屬性,以及屬性值,可以通過Get-EXOMailbox(或EXOMailbox)命令來實現。同時,該命令還可以為其它任務提供郵箱信息。
該命令的作用類似於舊版Exchange Online PowerShell的Get-Mailbox命令的功能,但根據微軟的介紹,提高了返回輸出效率和擴展了功能。
默認返回組織中所有郵箱的摘要列表(最少屬性集)。
1、完整語法
EXOMailbox
[[-Identity] <string>]/<string>
[-Archive]
[-ExternalDirectoryObjectId <guid>]/<guid>
[-Filter <string>]/<string>
[-InactiveMailboxOnly]
[-IncludeInactiveMailbox]
[-MailboxPlan <string>]/<string>
[-OrganizationalUnit <string>]/<string>
[-Properties <string>]/<string>
[-PropertySets <propertyset>]/<propertyset>
[-RecipientTypeDetails <string>]/<string>
[-ResultSize <unlimited>]/<unlimited>
[-SoftDeletedMailbox]
[-UserPrincipalName <string>]/<string>
[<commonparameters>]/<commonparameters>
或:
EXOMailbox
[-Anr <string>]/<string>
[-Archive]
[-Filter <string>]/<string>
[-InactiveMailboxOnly]
[-IncludeInactiveMailbox]
[-MailboxPlan <string>]/<string>
[-OrganizationalUnit <string>]/<string>
[-Properties <string>]/<string>
[-PropertySets <propertyset>]/<propertyset>
[-RecipientTypeDetails <string>]/<string>
[-ResultSize <unlimited>]/<unlimited>
[-SoftDeletedMailbox]
[<commonparameters>]/<commonparameters>
2、參數說明
Anr:
指定用於模糊查詢的字符串。命令將返回在某些屬性的值中包含該參數指定字符串的對象。具體參考Get-EXOCsaMailbox的Anr參數。
Archive:
指定返回啟用的存檔的郵箱。要執行該參數,必須要為組織管理員角色,或角色管理員角色。
其默認值為None。
ExternalDirectoryObjectId:
指定Azure Active Directory中郵箱的ObjectId標識來檢索查找顯示要查看的郵箱。
具體參考Get-EXOCsaMailbox的ExternalDirectoryObjectId參數。
Filter:
使用OPath語法對查詢的結果進行基於屬性和屬性值的篩選和查找。
具體參考Get-EXOCsaMailbox的Filter參數。
MailboxPlan:
按郵箱計劃篩選結果。指定該參數後,僅返回指定了郵箱計劃的郵箱。其參數值可以為任何唯一標識郵箱計劃的屬性值。包括:
- Name
- Alias
- Display Name
- Distinguished Name(DN)
- GUID
其默認值為None。
Identity:
指定查看的郵箱。
具體參考Get-EXOCsaMailbox的Identity參數。
InactiveMailboxOnly:
指定僅返回非活躍郵箱。要執行該參數,必須要為組織管理員角色,或角色管理員角色。非活躍郵箱是在軟刪除之前置於訴訟保留或就地保留的郵箱。其默認值為None。
IncludeInactiveMailbox:
指定返回活躍郵箱和非活躍郵箱。默認Get-EXOMailbox只返回活躍郵箱,需要同時返回非活躍郵箱,即需要使用該參數。要執行該參數,必須要為組織管理員角色,或角色管理員角色。其默認值為None。
OrganizationalUnit:
指定篩選對象所在AD中的OU名稱。
具體參考Get-EXOCsaMailbox的OrganizationalUnit參數。
Properties:
指定命令返回輸出的屬性。
具體參考Get-EXOCsaMailbox的Properties參數。
PropertySet:
指定命令返回輸出的屬性邏輯集,該命令支持的有效值有:
- Minimum(該集合為命令默認輸出)
- AddressList
- Audit
- Archive
- Custom
- Delivery
- Hold
- Moderation
- Move
- Policy
- PublicFolder
- Quota
- Resource
- Retention
- SCL
- SoftDelete
- StatisticsSeed
- All
其默認值為None。
RecipientTypeDetails:
指定子類型返回郵箱,其參數值包括:
- DiscoveryMailbox
- EquipmentMailbox
- GroupMailbox
- LegacyMailbox
- LinkedMailbox
- LinkedRoomMailbox
- RoomMailbox
- SchedulingMailbox
- SharedMailbox
- TeamMailbox
- UserMailbox
其默認值為None。
ResultSize:
指定要返回的最大查詢條目數。
具體參考Get-EXOCsaMailbox的ResultSize參數。
SofteDeletedMailbox:
指定返回被軟刪除的郵箱。要執行該參數,必須要為組織管理員角色,或角色管理員角色。
其默認值為None。
UserPrincipalName:
指定要查看郵箱的UPN。其默認值為None。
二、體驗Get-EXOMailbox
1、連接到Office 365的Exchange Online組織。
Connect-ExchangeOnline -UserPrincipalName [email protected] -ExchangeEnvironmentName O365China
2、直接使用默認參數值獲取前1000個郵箱對象的默認最小屬性集
Get-EXOMailbox
3、獲取指定用戶的郵箱基本信息。
Get-EXOMailbox lisi
4、獲取符合條件的指定條目數的對象。
Get-EXOMailbox -Anr "lpwr" -ResultSize 2
5、獲取指定子類型的郵箱對象。
Get-EXOMailbox -RecipientTypeDetails SharedMailbox
該用法的結果實際與使用Filter參數針對郵箱對象的RecipientTypeDetails屬性進行篩選SharedMailbox值等價。
Get-EXOMailbox -ResultSize Unlimited -Filter "RecipientTypeDetails -eq 'SharedMailbox'"
通過逗號分隔可以同時指定多個子類型的郵箱對象被返回。
Get-EXOMailbox -RecipientTypeDetails RoomMailbox,EquipmentMailbox
閱讀更多 技術直通車 的文章
關鍵字: 郵箱 PowerShell 微軟