samedi 24 juillet 2021

PowerShell: how to check how many digits were entered for user pin

I'm trying to write a powershell script that asks for a user to input a 4 digit pin, and if the number is not equal to 4, a warning is issued.

Here's what I have but it doesn't seem to work...

[int]$userPin = read-host 'type in your user pin'
if ($userPin.length -ne 4) {
  write-host "Error, Pin must be 4 numbers"
}

this code writes the error message no matter what... Any help is appreciated! THANKS!

Aucun commentaire:

Enregistrer un commentaire