Jana Sattainathan makes Jeff Hicks’s Read-HostSpecial better:
Some shortcomings of Read-HostSpecial
While it does a lot already, I did find some very minor shortcomings that I wanted to address
-
Bad inputs killed the program – If you are prompting for a series of inputs (like a wizard) and the user mis-keyed one input by mistake, the error recovery is very hard and the user has to start-over from the beginning. This called for a RepromptOnError switch which issues a gentle warning and then allows the user to input a valid value upon encountering validation errors.
-
I needed a couple of more canned validations like ValidateFolder and ValidateFile.
-
Too bad, there is no Write-HostSpecial – I wanted Read-HostSpecial to display some pretty text and not wait for input (like Write-Host) using the same nomenclature for fonts/look/feel/usability as Read-HostSpecial. So, I needed a NoWait switch.
Read on for Jana’s script and usage examples.