add a try block
Because of different password policies it makes sense to pack this function in a try block to let the user know if he's using a password which doesn't work
This commit is contained in:
parent
f381d38ee3
commit
e782225e8d
|
@ -11,6 +11,8 @@ Catch
|
|||
|
||||
function Reset-Password
|
||||
{
|
||||
Try
|
||||
{
|
||||
$username = Read-Host 'Please enter a user name'
|
||||
$default_password = 'default-password'
|
||||
Unlock-ADAccount -Identity $username
|
||||
|
@ -23,6 +25,13 @@ function Reset-Password
|
|||
-backgroundcolor green
|
||||
Write-Host
|
||||
Read-Host 'Press a key to continue'
|
||||
}
|
||||
Catch
|
||||
{
|
||||
Write-Warning $_
|
||||
Read-Host 'Press a key to continue'
|
||||
Break
|
||||
}
|
||||
}
|
||||
|
||||
Reset-Password
|
||||
|
|
Reference in New Issue