[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 70
  • Last Modified:

array of names to export to csv

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
Roccat
Asked:
Roccat
1 Solution
 
RoccatAuthor Commented:
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
 
QlemoDeveloperCommented:
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Tackle projects and never again get stuck behind a technical roadblock.
Join Now