How to automatically set the Application Pool Identity, User Name & Password

94 views Asked by At

Question

How can I automatically set the password of the Application Pool Identity from within a Windows commandline interface or script?

What I have Tried

I have tried to following command in command prompt:

C:\Windows\system32\inetsrv\appcmd.exe set config /section:applicationPools /[name='MyAppPool'].processModel.identityType:SpecificUser /[name='MyAppPool'].processModel.userName:MY_USER /[name='MyAppPool'].processModel.password:MY_PASSWORD

I get the error message:

Failed to process input: Duplicate parameters passed: section
(HRESULT=800700b7).

I have narrowed it down to being a problem with the password, as the following command does work:

C:\Windows\system32\inetsrv\appcmd.exe set config /section:applicationPools /[name='MyAppPool'].processModel.identityType:SpecificUser /[name='MyAppPool'].processModel.userName:MY_USER

I also tried running the password command on its own:

C:\Windows\system32\inetsrv\appcmd.exe set config /section:applicationPools /[name='MyAppPool'].processModel.password:MY_PASSWORD

But it gives this error instead:

ERROR ( message:Malformed collection indexer; format is [@position,name='value',name2='value2',...].  The @position specifier is optional, and be '@start', '@end', or '@N' where N is a numeric index into the collection. )
1

There are 1 answers

0
GatoSoft On

I was looking for how to do it, and I found this topic. I tried to do it as you say but finally I managed it with the other format:

set apppool "AppPoolName" /processModel.identityType:SpecificUser /processModel.userName:MY_USER /processModel.password:MY_PASSWORD