问题
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