Skip to content

Instantly share code, notes, and snippets.

@SweetAsNZ
Created January 26, 2026 20:24
Show Gist options
  • Select an option

  • Save SweetAsNZ/c372f9ea91f5dbeae6b630d9369ad528 to your computer and use it in GitHub Desktop.

Select an option

Save SweetAsNZ/c372f9ea91f5dbeae6b630d9369ad528 to your computer and use it in GitHub Desktop.
Set an AD Users Password
function Set-UserPassword {
<#
.SYNOPSIS
Change your AD password, use SAMAccount Name to change another users password
.DESCRIPTION
Change your AD password, use SAMAccount Name to change another users password
.EXAMPLE
Set-UserPassword
.EXAMPLE
Set-UserPassword -SAMAccountName 'jsmith'
.NOTES
Author: Tim West
Created: 27/01/26
Updated: 27/01/26
Status: Production
Version: 1.0
#>
[CmdletBinding()]
Param(
[string]$SAMAccountName
)
if(-not ($UserSAMAccountName) ){
$SAMAccountName = $ENV:USERNAME
}
$OldPassword = (Get-Credential -UserName $ENV:USERNAME -Message 'Old Password?')
$NewPassword = (Get-Credential -UserName $ENV:USERNAME -Message 'New Password?')
Set-ADAccountPassword $SAMAccountName -OldPassword $OldPassword.Password -NewPassword $NewPassword.Password -Confirm:$false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment