How to change windows user password with Powershell?

You can change windows users password with this function:

1
2
3
4
5
6
7
8
# Change Windows User Password
function change_password($username, $password)
{
$user = [adsi]("WinNT://localhost/$username, user")
$change = $user.psbase.invoke("SetPassword", "$password")
}
 
change_password "$username" "$password"

You should call function with 2 parameters named $username and $password.

Tags: , ,


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply