Object not found when running the command “set-spserviceapplicationpool” for web application
Introduction
Object not found when running the command “set-spserviceapplicationpool” for web application
Issue
Object not found error when running the command set-spserviceapplicationpool for web application.
Cause
Using the Set-SPServiceApplicationPool command we cannot change the application pool identity of a web application. The command only works to change the application pool identity for the service application in SharePoint.
Resolution
Follow the below PowerShell to change the identity of the Web Application pool:
$WebApplicaiton = Get-SPWebApplication https://webapp:port
$ManagedAccount = Get-SPManagedAccount -Identity "domain\username"
$WebApplication.ApplicationPool.ManagedAccount = $ManagedAccount
$WebApplicaiton.ApplicationPool.Update();
$WebApplication.Update()
Note: Resolved the issue by above method. If you find a different solution, please report it as a comment on this post. This will be useful to the SharePoint Community. Be sure to double-verify it: undo your solution and verify that the problem comes back, then redo it and verify that the problem goes away.