I am trying to populate an array based on how many csv files are in a folder. here is my code so far:
CD "\\domain\folder\file drop location"
$Array = Get-ChildItem -Filter *.csv |
Where-Object {-not $_.PsIsContainer} |
Foreach-Object {$_.Name}
$Array[0]
This returns different values depending on how many .csv files are in the folder. If only 1 csv is present then $Array[0]
returns the first character of the file name (I do not want this). If there are more than one csv files then it returns the entire file name (I DO want this). How do I cause the array to accept a single file as a 1-element array?
EDIT This question can be viewed as a duplicate unless you consider that amateurs/learners who don't understand PowerShell don't know how to phrase a question. My interpretation of the problem led me to dozens of pages which answered other problems, not mine.