Introduction
This posting explores how to change a web application pool identity using PowerShell methods. It assumes that both the current and target identities are configured as managed accounts (this makes things much simpler). You'll start out by first just reviewing the current identity of the web application. Next, you'll execute a few very simple scripts that change change the application pool configuration to the target managed account. All references used in this posting are listed below.
Procedure
This posting explores how to change a web application pool identity using PowerShell methods. It assumes that both the current and target identities are configured as managed accounts (this makes things much simpler). You'll start out by first just reviewing the current identity of the web application. Next, you'll execute a few very simple scripts that change change the application pool configuration to the target managed account. All references used in this posting are listed below.
Procedure
- Review existing web application pool identity
- Log into a SharePoint 2013 server using the SharePoint Setup User Administrator account (eg, spAdmin). This is the same account that you (should have) used to perform the initial farm installation and configuration.
This is important in that the changes you will be making will be to the farm configuration database; and, by default, only this account has the privileges necessary to make such changes.
- Launch an elevated SharePoint Management shell.
- Execute the following command, making appropriate revisions:
This lists out all the pertinent information concerning the web application pool's identity. A useful command to remember for future reference.$wa=Get-SPWebApplication "[YourSiteURL]" $wa.ApplicationPool - Implement the change
- Now, using the same management shell, execute the next few commands to make the change to the identity:
The change will be implemented immediately.$ma=Get-SPManagedAccount -Identity "[target managed account]" $wa.ApplicationPool.ManagedAccount=$ma $wa.ApplicationPool.Update() $wa.ApplicationPool.Deploy() - Verify the change
- Log into one of the farm WFEs hosting the web application - use any administrator account.
- Launch IIS Manager.
- In the Connections tree, expand Application Pools.
If you still see the original identity, press F5 to refresh - no need to recycle the application pool or perform an IIS reset.
References
- SharePoint User and Service Accounts
- Initial deployment administrative and service accounts in SharePoint 2013
- Account permissions and security settings in SharePoint 2013
- SharePoint 2013: Service Account Configurations and Permissions
- PowerShell
- Miscellaneous
Notes
- Executing the first three lines in step 2.1), above, updates the farm configuration database, but does not update the identity among the application pools on the web front ends. You can verify this by stopping after executing the Update() method, and then going to IIS on one of the WFEs and looking at the application pool identities listed there. So, to get the update pushed out to the WFEs, you must execute the Deploy() method of the ApplicationPool property.
7 comments:
Hi I get the 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
Go to: Central Administration > Security > General Security > Configure Managed Accounts. Is the account generating this error listed?
Yes. The account is very much in there. I did create the managed accounts before hitting the powershell.
Had the same issue while trying to change search service application's service account too. Niether "ManagedAccount" nor "Username" property is being identified in powershell. Then I had to change the script to something else to make search service applicaiton's identity to be changed.
Now I am running into the same problem while trying to change the service account for web application.
Run these:
$User=Get-SPUser -Identity "[serviceaccount in claims format]" -Web "[your web URL]"
$User | Get-Member
Is the ManagedAccount property listed?
Also run this without any arguments:
Get-SPManagedAccount
Do you see your target account listed?
Hey Al,
That was great, I couldn't get a help to see all properties. Get-Member function just saved me. Small silly thing just wastes a lot of time. Yes, "ManagedAccount" was not showing up as the property when initially tried on the variable. And target account wasa present too.
So it helped me figure out something is not setting the value on the variable and it was a typo on the variable name. Appreciate the help. I got it fixed.
Thanks,
Roby
Thank you so much. It really helped me out.
Post a Comment