Symptoms

POA task 'Delete SharePoint site' fails with the following error message:

Provisioning request failed. Unknown error 0x80131509 [<response><errorcontext description="An object in the SharePoint administrative framework, "SPApplicationPool Name=<NAME_OF_IDENTITY>", could not be deleted because other 

objects depend on it. Update all of these dependants to point to null or different objects and retry this operation. The dependant objects are as follows:

SPWebApplication Name=<WEBSPACE_ID> - domain (<DOMAIN_ID>)" code="0x80131509" executeseqno="6"><errorsource namespace="SPSManager" procedure="deleteApplicationPool"></errorsource></errorcontext></response>]

An attempt to delete SharePoint account also fails:

PS C:\Users\pem_admin> (Get-SPManagedAccount  -Identity <DOMAIN>\<NAME_OF_IDENTITY>).delete()
Exception calling "Delete" with "0" argument(s): "The account <DOMAIN>\<NAME_OF_IDENTITY> is still being used by these components:
Microsoft SharePoint Foundation Application Pool: <NAME_OF_IDENTITY>."

The SharePoint Central Administration panel does not allow to do this either:

The account <DOMAIN>\<NAME_OF_IDENTITY> is still being used by these components: 
Microsoft SharePoint Foundation Application Pool: <NAME_OF_IDENTITY>. 
Troubleshoot issues with Microsoft SharePoint Foundation. 
Correlation ID: <CORRELATION_ID> 
Date and Time: <DATETIME>   

Cause

In fact SharePoint site exist but the problem is that there is no HTTP-based URL in a problem SharePoint site like http://<WEBSITE_URL>:80; the site has HTTPS binding only.

It can be checked using the STSADM.exe utility on the SharePoint server:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN>STSADM.EXE -o enumusers -url http://<WEBSITE_URL>

The Web application at http://<WEBSITE_URL> could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN>STSADM.EXE -o enumusers -url https://<WEBSITE_URL>
<Users Count="1">
  <User>
    <Login>ADDOMAIN\wss-admin78321</Login>
    <Email>email@domain.com</Email>
    <Name>SharePoint Administrator</Name>
  </User>
</Users>

It can be verified in Powershell as well (on Windows 2008/2012):

check first if Microsoft.SharePoint.PowerShell snap is imported to Powershell and add it if it is missing

PS C:\Users\pem_admin> Get-PSSnapin
PS C:\Users\pem_admin> Add-PSSnapin Microsoft.SharePoint.PowerShell

PS C:\Users\pem_admin> Get-SPSite http://<WEBSITE_URL>
Get-SPSite : Cannot find an SPSite object with Id or Url: http://<WEBSITE_URL>
At line:1 char:11
+ Get-SPSite <<<<  http://<WEBSITE_URL>
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

PS C:\Users\pem_admin> Get-SPSite https://<WEBSITE_URL>

Url
---
https://<WEBSITE_URL>


PS C:\Users\pem_admin> Get-SPWebApplication https://<WEBSITE_URL>

DisplayName                    Url
-----------                    ---
<WEBSPACE_ID> - domain ... https://<WEBSITE_URL>

POA executes all requests to SharePoint objects using HTTP URL of a website. In result 'Delete SharePoint site' task cannot find SharePoint site with HTTP binding, decides that it was already removed and tries to remove other objects related to the site (including web application), then fails to dependencies because web application cannot be removed if site still exists.

This may happen if someone manually edited SharePoint site and removed its HTTP URL by removing the 'Alternate Access Mappings' binding.

Resolution

  1. Add alternative HTTP-based URL to the SharePoint site collection in question manually in the Sharepoint Central Administration panel > Application Management > Configure alternate access mappings > Add Internal URLs

  2. Re-run the failed task in the POA Task Manager.

Internal content