title: Powershell 7+ Cannot Administer IIS 10 with the IISAdministration Module
body: <p>The following code will work (only sometimes though ??) with older versions of PowerShell but not at all with version 7+.</p>
  <p>All I want to do is create a new Application Pool in IIS 10+.</p>
  <p>The documentation is very poor and most examples don't work anymore. Is there something I am missing here?</p>
  <pre><code>   # PowerShell 7.2.6
  
     # Windows Server 2019 (With the GUI).
  
     # IIS 10 etc is already installed.
  
     # Executed as Administrator.
  
     # NOTE: This imports the IISAdministration module not the old WebAdministration module.
     Import-Module -Name IISAdministration -UseWindowsPowerShell -WarningAction SilentlyContinue
  
     Reset-IISServerManager -Confirm:$false
  
     Start-IISCommitDelay
  
     # Create the foo.co.uk application pool.
     #
     # From this thread:
     #
     # https://github.com/MicrosoftDocs/windows-powershell-docs/issues/421
     #
     # And This one:
     #
     # https://blogs.iis.net/jeonghwan/how-to-use-iisadministration-powershell-cmdlets-to-configure-iis-configuration-settings
  
     Write-Host &quot;Creating the foo.co.uk application pool.`n&quot; -ForegroundColor Green
  
     $ServerManager = Get-IISServerManager
     $ServerManager.ApplicationPools.Add(&quot;foo.co.uk.apppool&quot;)
  
     # $ServerManager.CommitChanges() (this doesn't work though I keep seeing it in examples.)
  
     Stop-IISCommitDelay
  
  </code></pre>
  <p>I have now tried many examples of code that are similar to the above from the few online examples I can find and none of them work.</p>