Reputation: 5
I am trying to figure out how to do the following.
$number
into another command to add it to the new user.I have the following so far
$numbers = gc 'C:\temp\file.txt'
I can output the data by using $numbers[1]
, $numbers[2]
, etc., but how can I output this to look good and allow the user to select the best number with all options in the text file? I can do it manually obviously, but if I do 3 x $numbers[1]
, $numbers[2]
, $numbers[3]
it will miss the numbers 4, 5, 6 etc.
Upvotes: 0
Views: 876
Reputation: 17472
try Something like this :
$selected=Get-Content "c:\temp\phone.txt" | Out-Gridview -Title "Select your choice" -OutputMode Single
if ($selected)
{
Write-Host "your choice is $selected"
}
Upvotes: 2
Reputation: 10019
Something like this:
$numbers = Get-Content 'C:\temp\file.txt'
$i = 1
foreach($n in $numbers){
Write-host "Number $i - $n"
$i++
}
$n = Read-host "Choose a number"
$chosenNumber = $number[$n-1]
Upvotes: 1