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

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

實例以下:微信

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 -NoTypeInformationorm

同時咱們也能夠快速獲取當前郵箱包含azureyun.com信息的用戶數量:io

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

歡迎關注微信公衆號:小溫研習社coding

相關文章
相關標籤/搜索