Solved

array of names to export to csv

Posted on 2016-11-08
2
20 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
Comment Utility
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 68

Expert Comment

by:Qlemo
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 article will help you understand what HashTables are and how to use them in PowerShell.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now