IIS Application Pool configured to specific User MSA Account Through Powershell

0

I am not sure why it's happening but I am stuck in a point when I am trying to Configure my AppPool with a Specific Account i.e. MSA or Service Account.

I am running below script in PowerShell to do the configuration:

Import-Module WebAdministration
Set-ItemProperty IIS:\AppPools\AppPool -name processModel -value @{userName="$user_name";password="$password";identitytype=3}

The problem is that whenever I put Service account details through this script the AppPool is getting stopped and When try to start the AppPool multiple time the service account is getting locked. When I try to Configure manually in the AppPool it's working fine and works as Expected.

For Testing I tried to put my own ID credential in the above script and then its working fine as expected, but when I tried again with Service Account the result is same as above.

I tried multiple scripts to do so and result is same, in one of the script I found a strange error:

Set-ItemProperty : Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
At line:8 char:1
+ Set-ItemProperty IIS:\AppPools\AppPool -name processMode ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-ItemProperty], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.SetItemPropertyCommand

Can anyone help me to configure the Service Account in AppPool.

powershell
windows-server-2016
powershell-5.0
iis-10
asked on Stack Overflow Apr 13, 2020 by Manish Parida • edited Apr 13, 2020 by Manish Parida

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0