Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. $domain = 'someADDomain.local'
  2. $userName = 'SomeUser'
  3.  
  4. $oldPassword = Read-Host -AsSecureString -Prompt "Enter the account's old password"
  5. $newPassword = Read-Host -AsSecureString -Prompt "Enter a new password"
  6.  
  7. Set-ADAccountPassword -Server $domain -Identity $userName -OldPassword $oldPassword -NewPassword $newPassword
  8.  
  9.  
  10. $Password = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force $oldPassword
  11. $Credential = New-Object System.Management.Automation.PSCredential ("$domain\$userName", $Password)
  12. Set-ADAccountPassword -Credential $Credential -Server $domain -Identity $userName -OldPassword $oldPassword -NewPassword $newPassword
  13. # -----------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement