Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Uninstall Sharepoint Application - Invalid State

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.

like image 938
SliverNinja - MSFT Avatar asked Nov 03 '22 23:11

SliverNinja - MSFT


2 Answers

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.

like image 120
Vu Pham Avatar answered Nov 11 '22 02:11

Vu Pham


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).

like image 34
André Alves Avatar answered Nov 11 '22 03:11

André Alves