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:
Andreas Zweili 2017-07-15 13:06:47 +02:00
parent f381d38ee3
commit e782225e8d
1 changed files with 21 additions and 12 deletions

View File

@ -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