Friday, 24 June 2011

Resetting identity on web application pool from the command line

Ever wondered how to work with web application pools in IIS6 or IIS7 from the command line? See example below - it will (re)assign specific windows account for selected web application pool

SET SERVUSER=%COMPUTERNAME%\MyUser
SET SRVUSERPWD=PasswordHere
SET APPPOOLNAME=MyWebPool


echo will work for IIS6
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET w3svc/AppPools/%APPPOOLNAME%/WamUserName "%SERVUSER%"
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET w3svc/AppPools/%APPPOOLNAME%/WamUserPass "%SRVUSERPWD%"

echo will work for IIS7
%windir%\system32\inetsrv\appcmd set config /section:applicationPools /[name='%APPPOOLNAME%'].processModel.identityType:SpecificUser /[name='%APPPOOLNAME%'].processModel.userName:%SERVUSER% /[name='%APPPOOLNAME%'].processModel.password:%SRVUSERPWD%

No comments:

Post a Comment