Use powershell to reset password and unlock account
A neat script to choose the users OU in the AD, select the user and lets you choose what to do. Reset a password or unlock the users account.
The script uses the out-gridview with -passtru command to ask for your input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#define where the users are located in the AD $OUsearchbase = 'OU=Users,DC=company,DC=nl','OU=Users2,DC=company,DC=nl','OU=Users3,DC=company,DC=nl' #Select the right OU and User $user = Get-ADUser -Filter * -Properties LockedOut -SearchBase ( $OUsearchbase | Out-GridView -PassThru -Title "Select the location of the user" ) | Select-Object name,samaccountname,LockedOut,enabled | Out-GridView -PassThru -Title "Select the user" #Prompt for what action you would like to take $title = "Choose Action" $message = "What do you want to do to the user?" $ResetPassword = New-Object System.Management.Automation.Host.ChoiceDescription "Reset Password", ` "Reset the users password" $UnlockAccount = New-Object System.Management.Automation.Host.ChoiceDescription "Unlock account", ` "Unlock a locked user account" $options = [System.Management.Automation.Host.ChoiceDescription[]]($ResetPassword, $UnlockAccount) $result = $host.ui.PromptForChoice($title, $message, $options, 0) #take an action based on the selection switch ($result) { 0 {Set-ADAccountPassword -Identity $user.samaccountname -NewPassword (Read-Host -AsSecureString "Enter new password")} 1 {Unlock-ADAccount -Identity $user.samaccountname} } |