Resetting the password for multiple user accounts
Often, Windows administrators get requests to reset the password for a bunch of users. You can do this via a GUI approach if you have the time and patience. Otherwise, use the following function, which is an efficient way to do this. This function prompts for the password that you want to set for the users. This password should match the password complexity policy of your domain. You can pass the list of users to the UserName
parameter either as a Comma-Separated Value or by reading from a text file:
Function Reset-ADuserPassword { [CmdletBinding()] Param( [string[]]$UserName ) $Password = Read-Host "Enter the password that you want to set for the users" -AsSecureString foreach($User in $UserName) { try { Set-ADAccountPassword -Identity $User -Reset -NewPassword $Password -EA Stop Write-Host "Password successfully changed for $user" } catch { Write-Warning "Failed to reset password for $user. $_" }...