How to check whether an application pool exists or not in IIS using powershell and web administration module?
Use this:
import-module webadministration$AppPoolName="NewAppPool"if(Test-Path IIS:\AppPools\$AppPoolName){"AppPool is already there"return $true;}else{"AppPool is not present""Creating new AppPool"New-WebAppPool "$AppPoolName" -Forcereturn $false;}
Note: You need the WebAdministration module for Powershell. After importing you can use it. See the other ANSWER where I have mentioned about IIS drive