邮件不为空的Get-AdUser [英] Get-AdUser where mail is not null

查看:76
本文介绍了邮件不为空的Get-AdUser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取AD中所有具有电子邮件地址(邮件属性)的用户的列表。我有此命令

I am trying to get a list of all users in AD that have an email (mail attribute). I have this command

Get-AdUser -filter * -Properties mail | Select SAMAccountName, mail | Export-CSV -Path $userPath -NoTypeInformation

问题是我不知道如何限制或筛选出电子邮件为空/空白的用户。我不在乎脚本有多复杂,因为它将成为更大的Powershell脚本的一部分。如果解决方案是循环遍历CSV,则可以选择这种方法,但希望使用更快的方法。有人知道怎么做吗?

The problem is that I do not know how to limit or filter out users where the email is null/blank. I do not care how complex the script is as it will be part of a much larger powershell script. If the solution is to loop through the CSV that is an option but would prefer something quicker. Does anyone know how to do this?

推荐答案

尝试一下:

Get-ADUser -Properties mail -Filter {mail -like '*'}

这篇关于邮件不为空的Get-AdUser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆