Guest User

Untitled

a guest
Nov 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. function Prompt
  2. {
  3. param([string] $prompt, $validationScript)
  4. $rv = $null
  5. do
  6. {
  7. try
  8. {
  9. $input = Read-Host -Prompt $prompt
  10. $rv = Invoke-Command $validationScript -ArgumentList $input
  11. } catch
  12. {
  13. Write-Host "Invalid input, try again"
  14. }
  15. } while (!$rv)
  16. $rv
  17. }
  18.  
  19. $xxx = Prompt -Prompt "Enter integer" -validationScript {[Convert]::ToInt32($args[0], 10)}
  20. $xxx
Add Comment
Please, Sign In to add comment