Joseph Joseph - 1 year ago 174
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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download