Solved

array of names to export to csv

Posted on 2016-11-08
2
33 Views
Last Modified: 2016-11-09
I have an array of names in a variable. When I export to csv the names just come out as a list of numbers. How can I get the list to show up as the names?

$here = "jason","nicole","callie"
$DesktopPath = [Environment]::GetFolderPath("Desktop")
$here | Export-Csv -path $DesktopPath\names.csv -notype


It comes out as Length
5
6
6
0
Comment
Question by:Roccat
2 Comments
 

Accepted Solution

by:
Roccat earned 0 total points
ID: 41879819
I found my answer.

$here = "jason","nicole","callie"
$here = $here | Select-Object @{Name='Name';Expression={$_}}
$DesktopPath = [Environment]::GetFolderPath("Desktop")
$here | Export-Csv -path $DesktopPath\names.csv -notype
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41880005
You should just use Out-File instead of Expert-CSV if you want to store string arrays in a file.
A single-column files isn't really a CSV ;-).
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question