Export to CSV only returning string length

余生颓废 提交于 2019-12-12 03:50:10

问题


I'm trying to get this script to export to a CSV file, it only lists the string length and not the emails i am trying to pull.

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

回答1:


Export-Csv expects to receive an object, you've given it a string so it's giving you the properties of that string in the output file (that is, Length).

Drop -ExpandProperty and it will be fine.

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


来源:https://stackoverflow.com/questions/38875634/export-to-csv-only-returning-string-length

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!