none
Changing the Web Application Pool Identity using PowerShell

    Question

  • Hi,

     I writing Powershell scripts to do few setups in dev environment (like New web application, Enabling Self Service Site Creation, Changing My site Host Location, Changing the Application Pool Identity). I am stuck at the part of changing the application pool identity for the web application. Is it possible to change the applicaiton pool identity (which we usually do it through 'configure Service accounts' in CA) using Powershell?.


    Satheesh
    Wednesday, July 28, 2010 12:05 PM

Answers

  • After $WebApplication.ApplicationPool.Update() you can do a $WebApplication.ApplicationPool.Deploy() to push the change across all your WFEs.

    Tuesday, February 15, 2011 1:16 PM
  • Hi Prashanth,

    Thanks for your replay. I guess using the Set-SPServiceApplicationPool command we cannot change the application pool of a web application. I have tried and it always says that 'Object not found'.

    However i found another approach to do that

    $WebApplicaiton = Get-SPWebApplication https://servername:port

    $ManagedAccount = Get-SPManagedAccount -Identity "domain\username"

    $WebApplication.ApplicationPool.ManagedAccount = $ManagedAccount

    $WebApplicaiton.ApplicationPool.Update();

    $WebApplication.Update()    - Really not sure if we need this.

     

     


    Satheesh
    Wednesday, July 28, 2010 12:44 PM
  • Hi Satheesh,

    You are right. The Set-SPServiceApplicationPool command works only for updating the application pool account for service applications.

    Wednesday, July 28, 2010 1:14 PM

All replies

  • Hi Prashanth,

    Thanks for your replay. I guess using the Set-SPServiceApplicationPool command we cannot change the application pool of a web application. I have tried and it always says that 'Object not found'.

    However i found another approach to do that

    $WebApplicaiton = Get-SPWebApplication https://servername:port

    $ManagedAccount = Get-SPManagedAccount -Identity "domain\username"

    $WebApplication.ApplicationPool.ManagedAccount = $ManagedAccount

    $WebApplicaiton.ApplicationPool.Update();

    $WebApplication.Update()    - Really not sure if we need this.

     

     


    Satheesh
    Wednesday, July 28, 2010 12:44 PM
  • Hi Satheesh,

    You are right. The Set-SPServiceApplicationPool command works only for updating the application pool account for service applications.

    Wednesday, July 28, 2010 1:14 PM
  • Hi Prashanth,

    Need your help on one more thing. How to change the Search Service Account using PowerShell?

     


    Satheesh
    Wednesday, July 28, 2010 1:49 PM
  • Here is an outline:

    $osearchManagedAccount =  Get-SPManagedAccount -Identity "domain\username"
    $password = read-host -assecurestring
    Get-SPEnterpriseSearchService | Set-SPEnterpriseSearchService -ServiceAccount $osearchManagedAccount.Username -ServicePassword $password

    You can take the above and customize & expand it to suit to your needs.

    • Proposed as answer by Alpesh NAKAR Thursday, July 29, 2010 4:22 AM
    Wednesday, July 28, 2010 7:22 PM
  • It is possible to just assign the managed account without getting the password again?

    Satheesh
    Wednesday, August 04, 2010 2:41 PM
  • I don't think there is way to just assign the managed account without using the password. You can either use the above approach or probably use a  User Id (not managed account) & Password to  setup the service account. I would suggest you to go through the Managed Account approach.

    In the past, I have stored the password in a text file and used the password from the file directly instead of inputting the password everytime you run the script.

    Wednesday, August 11, 2010 5:12 PM
  • After $WebApplication.ApplicationPool.Update() you can do a $WebApplication.ApplicationPool.Deploy() to push the change across all your WFEs.

    Tuesday, February 15, 2011 1:16 PM
  • I am trying to use your script but you have not said what to do to replace the line

    $WebApplication.ApplicationPool.ManagedAccount = $ManagedAccount

    with what?

    I get the 'managedAccount' cannot be found on this object

    So is there something else that needs to be in place of that line or do I just remove it completely?


    WorkerBee09
    Wednesday, March 23, 2011 11:34 PM
  • A small open source utility for changing the Application pools in Sharepoint 2010.
    http://code.google.com/p/sharepoint-application-pool-changer/

    Nitin Gupta SharePoint Consultant
    Monday, July 25, 2011 7:56 AM
  • Hi Satheesh,

    Powershell Command worked for me.

    Thanks,

    Mohan Udupa

    Monday, May 28, 2012 11:01 AM
  • $WebApplication.ApplicationPool.Deploy() is a must to change it in the IIS appllication.  If you do not execute this command, the Managed Account will change in the config database, but changes would not take effect in the web servers.

    Great Answer

    Wednesday, November 27, 2013 4:44 PM
  • Hi,

    I have the similar requirement and when tried, I get this error constantly.


    The property 'ManagedAccount' cannot be found on this object. Verify that the property exists and can be set.
    At C:\Users\testUser\Desktop\Web App Managed Account.ps1:10 char:1
    + $WebAppPool.ManagedAccount = $ma
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

    Any Help would be appreciated

    Thursday, July 21, 2016 2:18 PM