Joseph Joseph - 2 months ago 13
PowerShell Question

Get App Pool Identity for IIS in Power Shell Script

Trying to get Application Pool Identity in IIS for a specific name, for example : Test

Succeded in getting it via below code but dont want to loop through all the webapps, is there any easy of getting it by specifying the name?

Import-Module WebAdministration

$webapps = Get-WebApplication
$list = @()
foreach ($webapp in get-childitem IIS:\AppPools\)
$name = "IIS:\AppPools\" + $
$item = @{}
if ($ -eq 'Test')
$item = $webapp.processModel.identityType

echo $webapp.processModel.identityType


Just combine the path and retrieve the item. This will work:

$item = Get-Item (Join-Path 'IIS:\AppPools\' 'Test') | 
   select -ExpandProperty processModel | 
   select -expand identityType