I am trying to do a simply read host and export the user input to a csv file.
$List = Read-Host -Prompt 'Enter List of files (exclude file extention)'|
Export-Csv "c:\user.csv" -NoTypeInformation
All I get in my file is:
"length"
"42"
I think I need to declare a custom object but what I want is:
User inputs:
filename1
filename2
export-csv C:\list.csv
should have:
filename1
filename2
Thanks!
You mentioned using a
PSCustomObject
, so why not use it?EDIT:
If you dont care about the file names being in a same column, you can use a
for
loop to iterate though all input (seperated by a comma), and passed into aPSCustomObject
. Now it shouldn't matter how much names they input.