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.
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
Here's a good source on arrays from PowerShell.com. It's specific to PowerShell version 2, but applicable to later versions.