powershelliisnetwork-service

IIS PowerShell Application Pool set as 'NetworkService' Account


I'm trying to create an Application Pool in IIS7 using PowerShell. I want this to run under the NetworkService account but currently this appears to try and set itself as an 'Other' user on the Application Pool rather than being recognised as a built-in account. My PS looks like this currently: Set-ItemProperty $iisAppPoolDir -name processModel -value @{userName="NetworkService";identitytype=3}

Now this usually should also have the password="*****"; field available to allow me to create the application pool and have the user log in. I've left this out, hoping it would be identifiable, but it's not worked.

Any help appreciated!


Solution

  • Network Service is its own identityType, so you would not set a username at all, and instead set the identityType to 2, like this:

    Set-ItemProperty IIS:\AppPools\MyAppPool -name processModel.identityType -value 2
    

    This will set the identity to Network Service.

    The identityType values are documented on the IIS website.