Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #A simple Powershell script to reset a target account's Active Directory password
  2. #Written by Kyle Fossum on 9/22/2017
  3.  
  4. #Prompt user for the account name and desired password
  5. $User = Read-Host -Prompt 'Enter the username'
  6.  
  7. $Password = Read-Host -Prompt 'Enter the password'
  8.  
  9. $PasswordCheck = Read-Host -Prompt 'Enter it again'
  10.  
  11. #Check if entered passwords match, and if so, reset the password and unlock the account
  12. if ($Password -eq $PasswordCheck)
  13.  
  14. {$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
  15. Set-ADAccountPassword -Reset -NewPassword $SecurePassword -Identity $User
  16. Unlock-ADAccount -Identity $User
  17. Write-Host "Success! $User has been reset to $Password"}
  18.  
  19. Read-Host -Prompt "Press Enter to exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement