Reputation: 37
Any help would be appreciated. I have script that runs and displays a list and ends with a question and prompt in my PowerShell ISE console. What I would like it to do is not scroll automatically to the question with the prompt, or I would like to automatically scroll to the top of the console window. I have tried derivatives of [System.Console]::SetWindowPosition and $psise.CurrentPowerShellTab.ConsolePane to absolutely no avail. It appears to me that it CAN'T be done or simply that I am misunderstanding something at a fundamental level and simply can't figure it out. Does anyone have a suggestion of how this can be done?
Upvotes: 0
Views: 533
Reputation: 702
I would suggest outputting our results in chunks until the results are complete and then display the question. In my sample:
I created a list of 35 user FirstName fields.
Displayed 10 results at a time with a read-host of "hit any key to continue"
After all the 35 results are displayed it asks the user a question.
$list = Import-Csv ".\data.csv"
$startrow = 0
$counter = 1
$rows = $list | Measure-Object
while ($startrow -lt $rows.Count)
{
$xs = $list | select-object -skip $startrow -first 10
foreach ($x in $xs)
{
Write-Host $x.FirstName -ForegroundColor Green
}
Read-Host "hit any key to continue"
$startrow += 10
$counter++
}
Read-Host "did you finish reading the output?"
Hope this helps you out. Feel free to modify it to your specifications.
Upvotes: 2