you need a file with the samAccountName of the users. The file with "Name", "Email", "Site", and "Position" fields doesn't work.
Use the script on your own risk. Not tested by myself.
$users = Get-Content -Path "UserNameList.txt"
foreach ($user in $users) {
# Set password
Set-ADAccountPassword -Identity $user -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force)
# Set ChangePasswordAtLogon
Set-ADUser -Identity $user -ChangePasswordAtLogon $true
}
The text file should contain only the username (samAccountName) of the users (one per row).
For instance:
Username1
Username2
Username3
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten