如何从 Windows 命令行界面或脚本中自动设置应用程序池身份的密码?
我尝试在命令提示符中执行以下命令:
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
我收到错误消息:
Failed to process input: Duplicate parameters passed: section (HRESULT=800700b7).
我已将其范围缩小为密码问题,因为以下命令确实有效:
C:\Windows\system32\inetsrv\appcmd.exe set config /section:applicationPools /[name='MyAppPool'].processModel.identityType:SpecificUser /[name='MyAppPool'].processModel.userName:MY_USER
我还尝试单独运行密码命令:
C:\Windows\system32\inetsrv\appcmd.exe set config /section:applicationPools /[name='MyAppPool'].processModel.password:MY_PASSWORD
但它却给出了这个错误:
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. )
我正在寻找如何做到这一点,我找到了这个主题。我试着按照你说的做,但最后我用其他格式做到了:
set apppool "AppPoolName" /processModel.identityType:SpecificUser /processModel.userName:MY_USER /processModel.password:MY_PASSWORD