Reading A File Name into a PowerShell Array

I am looking for some help when it comes to using Read-Host. Here is my issue, I want the user to type in the full file name "blah.txt" how do I store the whole file name into one element of my array? With what I have I keep getting each character not the whole text.

Thanks

Answers


How are you capturing the array? Here are two examples that illustrate how you could pull this into an array:

#Initialize the array first:
$array = @()
$array += Read-Host "Some Prompt"


#Alternatively, wrap results in array
$array = @(Read-Host "Some Prompt")

#Verify that the whole string is captured as an object in the array
$array[0]

Here's a good source on arrays from PowerShell.com. It's specific to PowerShell version 2, but applicable to later versions.


Need Your Help

Java org.apache.poi.unsupportedfileformatexception is missing

java excel apache

I have a Problem. I want to read the sheet name in a xlsx using XSSFWorkbook.

Extjs window is skewed after destoy

javascript extjs window

if you follow this wizard http://jsfiddle.net/8tBKa/ you will see that.