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.
control-ad/scripts/users/reset-password.ps1

29 lines
637 B
PowerShell
Raw Normal View History

2017-07-14 23:58:11 +02:00
# load ActiveDirectory module
Try
{
Import-Module ActiveDirectory -ErrorAction Stop
}
Catch
{
Write-Warning $_
Break
}
function Reset-Password
{
$username = Read-Host 'Please enter a user name'
$default_password = 'default-password'
Unlock-ADAccount -Identity $username
2017-07-15 10:49:13 +02:00
Set-ADAccountPassword -Identity $username -Reset -NewPassword
2017-07-14 23:58:11 +02:00
(
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
2017-07-14 23:58:11 +02:00
}