top of page

PowerShell - Reset User passwords from Txt

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 18, 2022
  • 1 min read

Rename the below as a ResetPasswordFromTXT.ps1 or similar self named, this takes all listed in the c:\temp\userlist.txt , it resets each with a random generated password that it lists on screen, and the user is prompted to change at login

# Import ActiveDirectory module

Import-module ActiveDirectory

# Grab list of users from a text file.

$ListOfUsers = Get-Content C:\Temp\userlist.txt

foreach ($user in $ListOfUsers) {

#Generate a 15-character random password.

$Password = -join ((33..126) | Get-Random -Count 15 | ForEach-Object { [char]$_ })

#Convert the password to secure string.

$NewPwd = ConvertTo-SecureString $Password -AsPlainText -Force

#Assign the new password to the user.

Set-ADAccountPassword $user -NewPassword $NewPwd -Reset

#Force user to change password at next logon.

Set-ADUser -Identity $user -ChangePasswordAtLogon $true

#Display userid and new password on the console.

Write-Host $user, $Password

}


 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page