Windows Server 2016-PS篩選導出用戶郵箱屬性包含某字段列表

生產環境中我們往往會遇到以多個郵箱別名結尾的情況,如何快速導出當前域用戶郵箱以某字段或後綴結尾的用戶列表信息變得尤爲重要,本例簡單彙總下如何通過Powershell快速篩選出當前郵箱信息包含azureyun.com的用戶列表並導出。

實例如下:

Get-ADUser -Filter * -SearchBase "OU=syncall,DC=azureyun,DC=com" -Properties name,mail |Where-Object {$_.mail -match "azureyun.com"} |Export-Csv c:\azureyun_mail.csv -Encoding utf8 -NoTypeInformation

同時我們也可以快速獲取當前郵箱包含azureyun.com信息的用戶數量:

(Get-ADUser -Filter * -SearchBase "OU=syncall,DC=azureyun,DC=com" -Properties name,mail |Where-Object {$_.mail -match "azureyun.com"} ).count

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章