You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用PowerShell从AD用户代理地址提取特定域名邮箱

修改PowerShell脚本提取特定域名的邮箱地址

修改后的完整脚本

Get-ADUser -Filter * -Properties proxyaddresses | 
    Select-Object Name, @{
        L = "TargetProxyAddresses"
        E = { 
            ($_.ProxyAddresses | Where-Object { $_ -like 'smtp:*@thisone.com' }) -join ";"
        }
    } | 
    Export-Csv -Path C:\PowerShell\AdUsersProxyAddresses.csv -NoTypeInformation

关键修改说明

  • 新增Where-Object过滤逻辑,精准匹配以@thisone.com结尾的SMTP格式代理地址,只保留目标域名的邮箱
  • 自定义属性名改为TargetProxyAddresses(若需保留原名可改回ProxyAddresses),更清晰区分提取后的结果
  • 保留原脚本的CSV导出逻辑,确保输出格式兼容现有需求

可选扩展

  • 若需区分主邮箱(大写SMTP开头)和别名邮箱(小写smtp开头),可调整过滤条件:
    • 仅提取主邮箱:$_ -like 'SMTP:*@thisone.com'
    • 仅提取别名邮箱:$_ -like 'smtp:*@thisone.com'
  • 若要排除无目标邮箱的用户,可在管道中添加Where-Object { $_.TargetProxyAddresses }

内容的提问来源于stack exchange,提问作者user18262192

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 06:57:36