do {
$user = $null
Write-Host "Please enter your credentials in order to connect you to the Azure AD."
$user = Get-Credential
if ($user -eq $null) {
Write-Host "Bad credentials. Please retry."
}
} while (!($user -eq $null))
This part of the script will allow the user to enter his credentials. I wanted to check if the user inputs something.
Problem is, if the user does not input something, the script works well and the user is forced to enter credentials.
But when I input something, I don't have any errors, but the script loops! It doesn't want to exit the loop.
Where am I wrong?
I've also tried
while ($user -eq $true)
but it doesn't work either. The user, even if he doesn't enter something, passed the while.
$user -eq $nullis the test for if the user has not entered credentials.!()reverses it. So you are looping while the user HAS entered credentials. Remove the!