IsraelTorres

passwordADUser.ps1

Mar 15th, 2012
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Israel Torres
  2. # 2012-03-14
  3. # Resets AD User password
  4. Import-Module ActiveDirectory
  5. #
  6. # args: username, password
  7. if($args.Length -eq 2){
  8. $username = $args[0]
  9. $password = $args[1]
  10.    if (!(Get-ADUser -filter {SamAccountName -eq $username})) {
  11.             Write-Host "User: $username does not exist; run .\CreateADUser.ps1 username password."        
  12.     }else{
  13.             Write-Host "Resetting password for User:$username"
  14.             Set-ADAccountPassword -Identity myTestAdmin -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $password -Force)
  15.     }
  16. }else{
  17.     Write-Host "Usage: .\passwordADUser.ps1 username password"
  18. }
  19. #EOF
RAW Paste Data