As you said, it does not alert about wrong password.
This is because powershell writes the username and password directly to the applicationhost.config file. Whether it is a Powershell or Appcmd command, the contents of the command are directly written to the applicationhost.config file. It does not verify that what was written is correct.
If you edit applicationhost.config directly, the file will also not verify that the content is correct. When you get a prompt message after changing your password in IIS Manager, it's because IIS Manager has built-in authentication.
So you need to add an authentication command to the powershell script to determine the password or username. Users that can usually be set as app pool identity are all users or user groups within the machine.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.