Import-Module WebAdministration
# Discovering IIS app pools
Get-Command -Name *apppool*
# Using the IIS drive
Get-ChildItem -Path IIS:\AppPools
Get-ItemProperty IIS:\AppPools\DefaultAppPool
# Using IIS cmdlet
Get-IISAppPool
# Finding the appliaction pool associated with a web site
(Get-Website -Name 'Default Web Site').applicationpool
# Looking at attributes
(Get-Item -Path 'IIS:\AppPools\DefaultAppPool').processModel
(Get-Item -Path 'IIS:\AppPools\DefaultAppPool').processModel.attributes | Select-Object -Property Name, Value
# Creating IIS app pools
New-WebAppPool -Name 'AutomateBoringStuff'
# IIS drive
New-Item -Path IIS:\AppPools\AutomateBoringStuff
# Setting attributes
Set-ItemProperty IIS:\AppPools\DefaultAppPool -Name processModel -Value @{username="user_name"; password="password"; identitytype=3}
(Get-Item -Path 'IIS:\AppPools\DefaultAppPool').processModel.attributes | Select-Object -Property Name, Value
# Restarting app pools
Restart-WebAppPool -Name AutomateBoringStuff
# removing IIS app pools
Remove-WebAppPool -Name AutomateBoringStuff