Windows Server 2016-ps filter export user mailbox property contains a field list

Time:2019-11-8

In the production environment, we often encounter the situation of ending with multiple mailbox aliases. How to quickly export the user list information of the current domain user mailbox ending with a certain field or suffix becomes particularly important. In this example, how to quickly filter out the user list of the current mailbox information including azureyun.com through PowerShell and export it under the simple summary.

Examples are as follows:

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

At the same time, we can quickly get the number of users whose current email contains azureyun.com information:

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

Welcome to WeChat public: Xiao Wen Xi she.