导出到 CSV 仅返回字符串长度

Export to CSV only returning string length

我试图让这个脚本导出到 CSV 文件,它只列出字符串长度,而不是我试图提取的电子邮件。

Get-ADGroup -filter {name -like 'Security Group'} | 
    Get-ADGroupMember -Recursive |
    Get-ADUser -Properties Mail |
    select -ExpandProperty Mail |
    Export-Csv -NoType MyCSVfile1.csv

Export-Csv 期望接收一个对象,您已经给它一个字符串,因此它在输出文件中为您提供该字符串的属性(即 Length)。

-ExpandProperty就好了

Get-ADGroup -filter {name -like 'Security Group'} |
    Get-ADGroupMember -Recursive |
    Get-ADUser -Properties Mail |
    Select Mail |
    Export-Csv -NoType MyCSVfile1.csv