iis - How to set application identity of an application pool using web administration module in powershell? -


i using powershell automate configuring websites in iis. have following code creates web application pool me

#creating new application pool new-webapppool "newapppool" 

how go setting application pool identity "network service" script ?

please note : there no iis drive on system. , hence commands have iis mentioned in path following fail :

set-itemproperty iis:\apppools\newapppool -name processmodel.identitytype -value 2 

when import webadministration module, powershell builds drive called iis. drive allows manage iis via file system using iis: instead of c: represent drive.

you can create pool like:

    new-item iis:\apppools\$apppool     $newpool = get-item iis:\apppools\$apppool     $newpool.processmodel.username = "$username"     $newpool.processmodel.password = "$password"     $newpool.processmodel.identitytype = 2     $newpool | set-item 

so using below command have use webadministration module:

set-itemproperty iis:\apppools\newapppool -name processmodel.identitytype -value 2 

hope helps.


Comments