5
votes

Our Sharepoint 2013 Application failed to install and is stuck in a odd state. I followed the recommended approach for deleting the application using powershell commands on the hosted Sharepoint server, but it doesn't execute properly.

Visual Studio Deployment/Retract Reports:

Skipping the uninstall step because the app for SharePoint is in an invalid state and cannot be uninstalled.

PowerShell Commands

$instances = Get-SPAppInstance -Web http://mysite/sites/collection
$instance = $instances | where {$_.Title -eq 'Application.Title'}
Uninstall-SPAppInstance -Identity $instance

Executing this PS command throws...

 The System Account cannot perform this action.

There is no option from the Sharepoint UI to remove the application, and retrying the install also fails. I've tried other user accounts to execute this powershell command (other than the system account), but no dice. I will have to delete the developer site collection if there is no other solution.

2
Did you check the permission to the user which you are using to develop app and uninstalling them..? Check the permission give appropriate permission to the user and then try to uninstall app.Rahul Gokani
Deleting the Site Collection is so far the only workaround I've found. I then recreate a collection using a different name.SliverNinja - MSFT
Try to check on your server if OWSTIMER.exe and Sharepoint Administration service is in running state.Redzio
Sadly, this still can happen. Visual Studio 2017 crashed on me while it was installing the add-in and that left it in an invalid state. From there you cannot retract, you cannot deploy, and the app does not appear in the UI in the site.tnk479

2 Answers

1
votes

I'm faced this problem before on my Office 365 SharePoint Online when deploy SharePoint Hosted App. Then I submit Microsoft Service request and work with MS Technical Support Team on this issue. This problem seem to be something error in SharePoint backend database by itself (I'm not sure to consider it is SharePoint defect).

Did you check the app details installation error report? If you get the message:

"The content database on the server is temporarily unavailable."

Need help: Error 'Install App for SharePoint': An instance of this App already exists at the specified location., I'm quite not understand the answer but there is one comment from Jeremy Thake which seem to be deleted on this thread, he said that:

"…so I actually just restarted the whole environment and when Windows came back up and I went to the SharePoint Site…the App was gone ;-)"

So here is my advice before you commit to delete your site collection:

  1. Try to deploy your to the another developer site collection and check whether this problem still occur as the same.
  2. Try to increase your app version or change app name/title/id and deploy to the same site collection and check whether this problem still occur as the same to your new app instance.
  3. For SharePoint Server, try to restart IIS/Window Server if you're able to do that. Also install any latest SharePoint Update/CU.
  4. For Office365 - SharePoint and have you have license account, you should submit the service request, if not you should wait about several day and try to remove this app instance again through UI.

Hope you can remove your app and know the root cause exactly.

1
votes

I have faced this issue some times in on-premises SharePoint.

But for solving this I gave another account (or you can use 1 that you have) shell admin rights.

Note this account CAN'T be marked as a System account on SharePoint!!

Then with this different shell admin account you execute the same script. That always worked for me (I also got some strange installation behavior and needed do remove the app).