I am trying to create a script that will detect pattern matches. I subbed some things from an old script. But I must be forgetting something. This script is suppose to match the pattern in a SS number and display the message… “you got it correct” or Please try again. The info I am missing has to be something simple…I just don’t see it. Any help any one can provide would be appreciated. Thanks
write-host “nnnnnn`n
“Press enter to Continue:””
Read-host
while ($question1 -ne $mynumbers){
Write-Host “Do you know the format of your SS Number ?”
write-host
write-host
write-host
$question1 = Read-Host “Please enter your SS Number and Press the enter key”
}
read-host
if ($question1 -eq $mynumbers){
write-host " You know your formats"}
if ($question1 -ne $mynumbers){
write-host “Please try again”}
Sorry, the forums software doesn’t take kindly to back ticks. You might want to revise your code listing.
The problem is that you’re using the -ne operator, which means “not EXACTLY equal to” and -eq, which means “EXACTLY equal to.” You probably want to look at the -match and -notmatch operators instead, which work with regular expressions.