简体   繁体   中英

Return only uppercase SMTP entries in get-aduser proxyaddresses

I am trying to return only the entries with uppercase SMTP in proxyaddresses. So far this is what I have:

get-aduser user.name -pr proxyaddresses |select proxyaddresses |? {$_ -cmatch '^SMTP\:.*'}

You don't really ask a question, so I'm going to infer a bit here. Either all you want is the ProxyAddress, or you want users where the ProxyAddress has upper case SMTP in it.

If all you want is the ProxyAddress then you were really close. Instead of just selecting the property with your Select command, you need to use the -ExpandProperty argument so that it expands that property and passes the values down the pipeline.

get-aduser user.name -pr proxyaddresses |select -ExpandProperty proxyaddresses |? {$_ -cmatch '^SMTP'}

If you want to get the users, and only check for the proxyaddress as an aside, you would skip the Select , and then specify the property in your Where statement as such:

get-aduser user.name -pr proxyaddresses |? {$_.proxyaddresses -cmatch '^SMTP'}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM