Skip to content

Instantly share code, notes, and snippets.

@ducas
Last active January 19, 2018 15:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducas/48a66c311f25c039741b to your computer and use it in GitHub Desktop.
Save ducas/48a66c311f25c039741b to your computer and use it in GitHub Desktop.
Change a local user account's password using PowerShell
$Username = "su"
$Password = "password"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }
if ($existing -eq $null) {
Write-Error "User $Username does not exist"
return
}
$existing.SetPassword($Password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment