This repository has been archived on 2020-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
2017-07-14 23:58:11 +02:00
|
|
|
# load ActiveDirectory module
|
|
|
|
Try
|
|
|
|
{
|
|
|
|
Import-Module ActiveDirectory -ErrorAction Stop
|
|
|
|
}
|
|
|
|
Catch
|
|
|
|
{
|
|
|
|
Write-Warning $_
|
|
|
|
Break
|
|
|
|
}
|
|
|
|
|
2017-07-15 13:08:19 +02:00
|
|
|
#Specify your default password here
|
|
|
|
$default_password = 'default-password'
|
|
|
|
|
2017-07-14 23:58:11 +02:00
|
|
|
function Reset-Password
|
|
|
|
{
|
2017-07-15 13:06:47 +02:00
|
|
|
Try
|
|
|
|
{
|
|
|
|
$username = Read-Host 'Please enter a user name'
|
|
|
|
Unlock-ADAccount -Identity $username
|
|
|
|
Set-ADAccountPassword -Identity $username -Reset -NewPassword (
|
|
|
|
ConvertTo-SecureString -AsPlainText $default_password -Force
|
|
|
|
)
|
|
|
|
Set-ADuser $username -ChangePasswordAtLogon $True
|
|
|
|
Write-Host
|
|
|
|
Write-Host 'Password of ' $username 'reset to ' $default_password `
|
|
|
|
-backgroundcolor green
|
|
|
|
Write-Host
|
|
|
|
Read-Host 'Press a key to continue'
|
|
|
|
}
|
|
|
|
Catch
|
|
|
|
{
|
|
|
|
Write-Warning $_
|
|
|
|
Read-Host 'Press a key to continue'
|
|
|
|
Break
|
|
|
|
}
|
2017-07-14 23:58:11 +02:00
|
|
|
}
|
|
|
|
|
2017-07-15 12:36:38 +02:00
|
|
|
Reset-Password
|