I have been having lots of difficulty automating the setup of a Web application and configuring IIS appropriately with the Application Pool Identity. I am doing this in a Web a
I'm on powershell v4 which doesn't have 'ConvertFrom-SecureString', in the end I got the following to work for me:
Import-Module WebAdministration
$cred = Get-Credential -Message "Please enter username and new password to reset IIS app pool password (for app pools running as username)"
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($cred.Password)
$plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)
$applicationPools = Get-ChildItem IIS:\AppPools | where { $_.processModel.userName -eq
$cred.UserName }
foreach($pool in $applicationPools)
{
$apppool = "IIS:\AppPools\" + $pool.Name
Set-ItemProperty $apppool -name processModel.password -Value $plaintext
}
Write-Host "Application pool passwords updated..." -ForegroundColor Magenta
Write-Host ""
Read-Host -Prompt "Press Enter to exit"