Deleting and Recreating a Service Account in SharePoint

I recently had an adventure with a customer related to the need to delete and recreate a service account in SharePoint, retaining the exact name before and after recreation. Of course, we had to do this without being able to remove it from SharePoint cleanly beforehand. Unfortunately, this didn’t go so smoothly, and the main hiccup I was having was in trying to remove the (now defunct) service account from the registered accounts list in SharePoint Central Admin. Basically, trying to delete the account (using the GUI) failed with (one of the two) error messages below (depending on what I was doing in the GUI).

Errors I Was Seeing

Error #1: Some or all identity references could not be translated.

Error #2: The given key was not present in the dictionary.

The Steps I Followed to Resolve the Issue

** I’d recommend you read through this before blindly following these steps, there was definitely a few dead ends **

To start, the name of the service account was “spserviceapppool”

  1. I added the “spserviceapppool” account into SharePoint Central Admin under “service accounts” in “Security”.
  2. Yay, now I had two spserviceapppool accounts – this was not what I had intended
  3. Next, I deleted the account I just added (in the GUI)
  4. After that, I removed the old references from all the associated service applications as I was getting the following issue.

  5. I found these were the best steps to follow (included below), though they weren’t entirely applicable to my situation:
  • I have to create a new domain account that would become the Farm Administrator account and set this with a static password
  • Use PowerShell to try and remove the offending (old) farm administrator account – this will result in an error as there are several services that are still using this old farm admin account, the error message will list all these services.
  • Use the SharePoint Central Administration to move these services to use the new farm account. The first time you do this you can “Register a new managed account”, as you are configuring the services.
  • Work through the list of services that need to be moved to the new farm account
  • There might be one or two services that you will need to use PowerShell to change as they are not listed in the GUI. Use Google to search for info on how to do this – it isn’t too complicated
  • When all the services that used to use the old farm account have been moved to use the new one, you can use PowerShell to remove the old Farm account and this should hopefully go through successfully
  • This should make the “Configure Managed Accounts” page in the SharePoint Central Admin work again
  1. Still, once the account was removed from all service applications, I could not delete the account.
  2. Remove-SPManagedAccount -Identity DOMAINServiceAcct

  3. Unfortunately, that too failed with same “given key not present in dictionary” error
  4. Eventually I came across this article
  5. This led me to try this:

    $ma = Get-SPManagedAccount -Identity “<domain><account>”

    Remove-SPManagedAccount $ma

  6. At last, the above PowerShell worked and my old account was finally removed
  7. Finally, added the new account, reassociated it to the appropriate service applications, and all was solved.