I found this post helpful. PowerShell - User Must Change Password at Next Logon
Is it possible to force a user to set a password on next sign in by using something like this?
Set-LocalUser -ChangePasswordAtLogon:$true
I get a NamedParameter error when trying the script above.
What's the best way to force a local user account to reset a password upon login?
The Set-LocalUser cmdlet does not have a parameter ChangePasswordAtLogon
Try
Set-LocalUser -Name "TheUser" -PasswordNeverExpires $false
or use
$user = [ADSI]"WinNT://$env:ComputerName/TheUserName,user"
$user.PasswordExpired = 1
$user.SetInfo()