title: Use PowerShell to Create AppPool does not set AppPool Identity
body: <p>I am attempting to use PowerShell to create an Application Pool in IIS.  After searching the web, I created the following test script:</p>
  <pre><code>Import-Module WebAdministration
  
  $siteName = &quot;TestAppPool&quot;
  $userAccountName = &quot;Domain\UserName&quot;
  $userAccountPassword = &quot;MyPassword&quot;
  
  if(!(Test-Path (&quot;IIS:\AppPools\&quot; + $siteName)))
  {
       $appPool = New-Item (&quot;IIS:\AppPools\&quot; + $siteName)
  
       #Display Default AppPool Settings
       &quot;AppPool = &quot; + $appPool
       &quot;UserName = &quot; + $appPool.processModel.userName
       &quot;Password = &quot; + $appPool.processModel.password
       &quot;Runtime = &quot; + $appPool.managedRuntimeVersion
       
       $appPool.processModel.userName = $userAccountName
       $appPool.processModel.password = $userAccountPassword
       $appPool.managedRuntimeVersion = &quot;v4.0&quot;
       $appPool | Set-Item
  
       #Display Updated AppPool Settings
       &quot;AppPool = &quot; +$appPool
       &quot;UserName = &quot; + $appPool.processModel.userName
       &quot;Password = &quot; + $appPool.processModel.password
       &quot;Runtime = &quot; + $appPool.managedRuntimeVersion
  }
  </code></pre>
  <p>When I run the script, the user name and password are not updated to the values I set.</p>
  <p>Here are the results from the two print blocks</p>
  <pre><code>#Display Default AppPool Settings
  AppPool = Microsoft.IIs.PowerShell.Framework.ConfigurationElement
  UserName = 
  Password = 
  Runtime = v2.0
  
  #Display Updated AppPool Settings
  AppPool = Microsoft.IIs.PowerShell.Framework.ConfigurationElement
  UserName = 
  Password = 
  Runtime = v2.0
  </code></pre>
  <p>Looking in IIS, the Application Pool shows the .Net Framework was updated, yet the Identity is still set to ApplicationPoolIdentity.  It should be Domain\UserName.</p>
  <p><img src="https://i.stack.imgur.com/0rtQ3.png" alt="enter image description here" /></p>
  <p>I'm an admin on the machine, and I am running PowerShell in Administrator mode.  Any ideas as to what I may be missing to get this to work?</p>