Skip to content

Instantly share code, notes, and snippets.

@fokklz
Created June 19, 2023 12:08
Show Gist options
  • Save fokklz/6396939ddd740808a9b079dc7f2573d6 to your computer and use it in GitHub Desktop.
Save fokklz/6396939ddd740808a9b079dc7f2573d6 to your computer and use it in GitHub Desktop.
function ValidateUsername {
param(
[Parameter(Position = 0)]
[string]$Username
)
$onlyLetters = "[a-zA-Z]"
$blacklist = @("admin", "administrator")
if($Username -notmatch $onlyLetters){
return $false
}
if($blacklist -contains $Username){
return $false
}
return $true
}
ValidateUsername "admin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment