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.
Best regards,
Bruce Zhang
Hi MSFT,
in the below script i am updating the wrong password "password"
Invoke-Command -ComputerName "somecomputer" -Credential $cred -ScriptBlock {
Import-Module WebAdministration
$applicationPools = Get-ChildItem IIS:AppPools | where { $_.processModel.userName -eq "devuser" }
echo $applicationPools
foreach($pool in $applicationPools)
{
Write-Host "Pool Name is $($pool.name)"
if($pool.name -eq 'ACMAppPool') {
$pool.Stop()
$pool.processModel.userName = "Americas\ProcessMIASDev"
$pool.processModel.password = "password"
$pool.processModel.identityType = 3
$pool | Set-Item
$pool.Start()
Write-Host "Last exit code $($LASTEXITCODE)"
Write-Host "Application pool passwords updated..." -ForegroundColor Magenta
Write-Host "Hi"
}
}