I have a powershell script where I want the user to input a value and the script returns a randomized string for a password. If they just hit enter when prompted for the length of the password, I want it to be a default of 9 characters.
How do I handle no input?
I tried something like this, but don't think it is quite right:
Write-Host Enter the password length requirement:
$length = Read-Host
IF ( $length -eq $NULL)
{ Do continue on with the value of 9 for the length}
ELSE
{Use $length for the rest of the script}
The else portion works just fine; however when generating passwords I keep finding myself typing 9 over and over again. I'd rather just hit enter.
Any help is greatly appreciated!