Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Powershell re-prompt for entry

$
0
0

Hello. I'm user a powershell script that prompts for multiple entries and certain entries require a user to input a particular value. What I would like to do is if the user's input is not equal to those values, re-prompt the user to enter the entry again until they do enter the correct value. So for example one input asks for a Y or N if email will be forwarded.

$WillMail = read-host "Will mail be forwarded? Enter Y or N "

Ideally if the entry is something other than "Y" or "N", I'd like it to ask something like "That is an incorrect value. Please enter Y or N".


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>