Powershell – IIS 8: Setting the application pool username is ignored

iis-8powershellwindows-server-2012

I do this on IIS 7.5:

Create an application pool, "testpool", and set the username and password to match one that exists in the AD. Then in powershell as administrator:

  • Import-Module webadministration
  • cd IIS:\AppPools
  • Get-ItemProperty "testpool" -name "processmodel.username"

It gives me the correct username. Then:

  • Set-ItemProperty "testpool" -name "processmodel.username" -value "mydomain\anotheruser"
  • Get-ItemProperty "testpool" -name "processmodel.username"

It gives me the new username, mydomain\anotheruser. However, on IIS 8, the last line still gives me the old username, but the line above it does not result in an error.

Edit:

We are creating scripts for configuring all our webservers. It would be rather annoying if setting the username is not possible when scripting.

I've tried this on many IIS 7.5 servers (Windows 2008) and they all work. I've tried it on three IIS 8 servers (Windows 2012) and none of them work.

It turns out that although I cannot set the username, I can set the password on IIS 8:

  • Set-ItemProperty "testpool" -name "processmodel.password" -value "MyPassword"

Best Answer

i do this in IIS 8

$testpool = get-item iis:\apppools\$iisAppPoolName;
$testpool.processModel.userName = $un;
$testpool.processModel.password = $pw;
$testpool.processModel.identityType = 3;
$testpool | Set-Item
$testpool.Stop();
$testpool.Start();

Works for me :)