powershell - 导出电子邮件地址-删除所有包含数字的电子邮件地址

标签 powershell exchange-server office365

我有以下powershell脚本:

    Get-Mailbox -ResultSize Unlimited | Select-Object PrimarySmtpAddress | Export-Csv c:\userlist.csv -NoTypeInformation
Send-MailMessage -from noreply@domain.com -to username@domain.com -subject "Email Addresses" -Attachment "c:\userlist.csv" -SmtpServer relay-server 

这给了我所有的电子邮件地址作为交换。我有一堆电子邮件地址,地址中的数字如下所示:

123@domain.com

我如何处理数据,以便仅导出包含字母的电子邮件地址?我不希望将其中包含数字的任何电子邮件地址导出到userlist.csv文件。

最佳答案

将Where-Object cmdlet与-NotMatch一起使用

Get-Mailbox -ResultSize Unlimited | Where-Object { $_.PrimarySmtpAddress -NotMatch "\d" } | Select-Object PrimarySmtpAddress | Export-Csv c:\userlist.csv -NoTypeInformation
Send-MailMessage -from noreply@domain.com -to username@domain.com -subject "Email Addresses" -Attachment "c:\userlist.csv" -SmtpServer relay-server 

关于powershell - 导出电子邮件地址-删除所有包含数字的电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12487079/

相关文章:

windows - 如何从 Powershell 脚本切换目录的加密属性?

office365 - Office 365 API - 创建 session 室

powershell - 使用 PowerShell 将文件从 tfs 版本控制复制到目录

windows - Powershell DSC Pull Server 抛出内部错误 - Microsoft.Isam.Esent.Interop not found

powershell - 冒号作为参数中的字符串

exchange-server - 传输代理会在日志记录发生之前执行 Exchange 2013 吗?

active-directory - 什么 ldap 查询返回现在从事件目录中删除的用户对象?

excel - 使用 OfficeJs 和 ReactJS 在 Excel 插件中保存功能

azure - Microsoft Graph 'created' 订阅无法使用应用程序 token

SharePoint 导出到 excel 在谷歌浏览器中不起作用