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

导出AD用户msExchExtensionCustomAttribute2至CSV异常,请求协助

解决AD用户属性导出CSV/TXT的问题

问题原因

你使用-ExpandProperty后,输出的是msExchExtensionCustomAttribute2的原始值(比如字符串),而Export-Csv是针对对象导出的工具,它会提取该值的内置属性(比如字符串的Length)作为CSV列,导致输出并非你需要的属性内容。

解决方案

方案1:导出带属性名的CSV

保留对象结构,明确指定要导出的属性列:

Get-ADUser -Identity test -Properties msExchExtensionCustomAttribute2 | 
    Select-Object @{Name='msExchExtensionCustomAttribute2'; Expression={$_.msExchExtensionCustomAttribute2}} |
    Export-Csv -Path C:\temp\test.csv -NoTypeInformation

方案2:导出纯文本到TXT

如果只需要属性的纯文本值,直接用Out-File更简单直接:

Get-ADUser -Identity test -Properties msExchExtensionCustomAttribute2 | 
    Select-Object -ExpandProperty msExchExtensionCustomAttribute2 |
    Out-File -Path C:\temp\test.txt -Encoding UTF8

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 05:42:02