MacOS Reset Passcode not working- Urgent

I have tried to deploy passwordpolicy script using pwpolicy

pwpolicy -n /Local/Default -setglobalpolicy "usingHistory=5 canModifyPasswordforSelf=1 maxMinutesUntilChangePassword=129600 requiresAlpha=1 requiresNumeric=1 minChars=8 passwordCannotBeName=1 requiresMixedCase=1 requiresSymbol=1"
sudo defaults write /Library/Preferences/com.apple.loginwindow PasswordExpirationDays 14
errcode=$?
if [ "$errcode" -ne 0 ];
then
echo ""
echo "Failed to apply with errorcode $errcode" 1>&2
echo ""
exit 1
fi
echo "Password Policy applied successfully" 1>&2

After deploying, on next login, It prompted for login, On entering password, It shows wrong password. When I tried to reset the password, It is not accepting the password. Instead It prompts again and again.

Like this , I have got 300 mac machines struck in login page. I tried to run these two commands via a app running in root

pwpolicy -u "$user" -clearaccountpolicies
pwpolicy -clearaccountpolicies

After Running this, I can able to loggin for first time. When tried to login second or successive times, It is failing with wrong password or sometimes no error instead of a jumping prompt in password page.

When tried to change password after a login after clearpolicy command, It is not accepting the admin's password (Which was used to login the current session).

Please help on this issue. As it does have a serious impact.