Created
January 26, 2026 20:24
-
-
Save SweetAsNZ/c372f9ea91f5dbeae6b630d9369ad528 to your computer and use it in GitHub Desktop.
Set an AD Users Password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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