79833561

Date: 2025-11-29 21:53:05
Score: 0.5
Natty:
Report link

Not an answer to your (already answered) question, but a different approach to your menu.
Instead of handcrafting a menu, an easy way to provide a selection in PowerShell is to use the underrated Out-GridView.
By default, it will just show whatever it is told to show, and the script will continue.
But with the -PassThru or the -OutputMode parameter, it will wait for the user to select something, and return the row(s) selected.
So your menu part of the script could look like this:

# Multiple distinct log folders found
Write-Host "Multiple script directories were found in the command list."
Write-Host "Please select one in the form that just popped up."

$chosenLogFolder = $uniqueLogFolders | Out-GridView -Title "$($MyInvocation.MyCommand.Name): found multiple script directories; select one to use for logging:" -OutputMode Single
If (-not $chosenLogFolder) {
    Write-Warning 'No folder selected, aborting.'
    Return
}
Reasons:
  • Blacklisted phrase (1): Not an answer
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: user314159