So i want a script that sets the Administrator password. I want the user to input it twice and then check if it matches. Ive already tried to switch the conditions -eq and -ne in the two if statements, but it didnt change anything
$Password = Read-Host -AsSecureString 'Passwort des lokalen Administrators setzen' #input admin password
$PasswordRepeat = Read-Host -AsSecureString 'Passwort wiederholen' #repeat password
if ($Password -eq $PasswordRepeat) {
$UserAccount = Get-LocalUser -Name "Admin"
$UserAccount | Set-LocalUser -Password $Password
'Passwort wurde gesetzt' #password was set
''
Read-Host 'Enter druecken um das Script zu schliessen' #press enter to close
}
elseif ($Password -ne $PasswordRepeat) {
'Passwoerter stimmen nicht ueberein' #passwords do not match
''
Read-Host 'Enter druecken um das Script zu schliessen' #press enter to close
}
So when the password and passwordrepeat match it should change the password and output that the password is set. But if i input the same password twice it also prints out that the passwords do not match, and when i input two different passwords it also says that they dont match
Aucun commentaire:
Enregistrer un commentaire