Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog



Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

Installing SharePoint 2013 apps with PowerShell

My PowerShell posts always prove to be the most popular.  I showed all sorts of cool PowerShell tricks in my talk back at SPC12.  One of the things I covered was how to install and manage apps using PowerShell.  Since there is a corporate catalog and SharePoint store, you might not think you need to install apps with PowerShell, but your developers may choose to the app model for a future internal project, so as an IT Pro you need to know how to install the thing.  There are a lot of similarities to working with solution packages but there are several differences to be aware of.  The documentation on TechNet is pretty good, but putting it all together can be tricky.

Specific to PowerShell, there is some terminology to familiarize yourself with.  You’ll see these for parameter names so you need to know what they are otherwise you’ll find yourself confused.

  • App Package – physical file containing the app (.app file)
  • App – an instance of an app installed on a particular subsite

Along with the App, you’ll find an Id property that refers to a GUID of that particular app instance.  We’ll talk about that more when it comes to updates.

To begin installing app, we first install the .app file into a site collection and then we deploy the app to an individual subsite.  To install the app package, we use Import-SPAppPackage.  Specify the path to your app package (.app file) with the –Path parameter.  You’ll also need to specify which Site Collection will contain the app using the –Site parameter.  Finally, the Source parameter tells SharePoint where the app came from (SharePoint Store, Corporate Catalog, or Object Model).  I always specify a value of ObjectModel for my custom apps.  Here’s what the command looks like.  Assign the results of the command to variable so that you can use it in the next step.

$spapp = Import-SPAppPackage -Path .\ -Site http://server/sitecollection –Source ObjectModel


You can always add –confirm:$false to avoid getting prompted.

Now you have the AppPackage installed, you can deploy an instance of it to a subsite using Install-SPApp.  You’ll need to provide a URL to the subsite using the –Web parameter and a reference to the imported app package.  That’s why we saved the results of the last command into $spapp.  Use the following command.

$instance = Install-SPApp -Web http://server/sitecollection/site -Identity $spapp


Like always with PowerShell, no news is good news.  At this point, you should find the app installed on the Site Contents pages.


Here’s what it looks like it is running.  This is mainly for reference when we start talking about updates.


To determine what apps are installed on a particular subsite use Get-SPAppInstance.  This cmdlet can be executed three different ways.  You need the id of the App Instance to update, export, or remove it.   So often you combine it with a Where-Object command to get a reference to an app instance by name instead of by id.

$instance = Get-SPAppInstance -web http://server/sitecollection/site | Where-Object { $_.Title -eq "MyApp" }


Once you have a reference to the App Instance, removing the app from a subsite is easy with Uninstall-SPAppInstance.

Uninstall-SPAppInstance -Identity $instance


One nice feature of PowerShell is that you have the ability to export an installed app to a .app file using Export-SPAppPackage.  It takes a parameter named -App.  It expects the value from an instance called .App (so use Get-SPAppInstance as shown above).  You also want to specify where to save the file using the –Path parameter.

Export-SPAppPackage –App $instance.App –Path .\


When it comes to updating apps, that’s where things get a bit tricky.  Here is what you need to do:

  • Get a reference to the existing installed instance using Get-SPAppInstance shown earlier
  • Import the new app package with Import-SPAppPackage
  • Use Update-SPAppInstance with a reference to the imported app package and the existing instance

Here are the commands

$instance = Get-SPAppInstance -web http://server/sitecollection/site | Where-Object { $_.Title -eq "MyApp" }

$spappv2 = Import-SPAppPackage -Path .\ -Site http://server/sitecollection/site -Source ObjectModel

Update-SPAppInstance – Identity $instance –App $spappv2


One thing you might have noticed by now is that there is no way to retrieve which app packages are installed nor is there any way to remove them using PowerShell.  This is a bit different than the way we deal with solution packages.  I suspect it cleans itself up, but I’m really not sure.  I hope these PowerShell commands prove to be useful to you.  Let me know if you run into any issues.



Shilpa said:

Nice article.

March 1, 2013 3:03 AM

Installing SharePoint 2013 Apps | Sladescross's Blog said:

Pingback from  Installing SharePoint 2013 Apps | Sladescross's Blog

March 4, 2013 1:08 AM

Installing SharePoint 2013 apps with PowerShell - Corey Roth [MVP] | SharePoint Resources | said:

Pingback from  Installing SharePoint 2013 apps with PowerShell - Corey Roth [MVP] | SharePoint Resources |

March 12, 2013 12:10 PM

Tim Vivian said:

Great Article Corey.  Very useful information that I can use in my own automation strategy.

March 12, 2013 12:42 PM

VIvek said:

Can we add APPS to Pages programatically? I have a sharepoint hosted app which i have to place on my subsite as soon as the site gets created. This is a functionality i need as part of my site Provisioning. Can you please help me figure out if this task is achievable using APP model?

August 6, 2013 11:46 PM

Juan said:

If I try and uninstall some apps I get the following error:

"Uninstall-SPAppInstance : The App package has not been downloaded."

October 22, 2013 4:56 AM

Robert said:

I get an invalid data error when trying to uninstall an app.  This is at the root site collection of my web application.  What am I missing?

December 19, 2013 7:56 AM

Greg Thatcher said:

Great post.  Thanks for the info on updating -- haven't seen this explained correctly anywhere else.

September 22, 2014 3:57 PM

Srikanth said:

Hi Corey,

I uploaded an app to my app catalog. Is there a way to deploy this app to my other site collection programatically?

September 30, 2014 10:30 AM

Phil said:

I notice you're installing to a developer site. Can PowerShell only be used to manage apps on sites with "sideloading" enabled?

October 7, 2015 2:13 PM

Rajesh said:

Hi Corey - All the powershell commands in this blog applies to On-premise SharePoint APP installation i believe. How can we Register/Install App in a SharePoint Online site ?


October 16, 2015 8:56 PM

Kai said:

Hello I am getting an error whith the updating function. It says "the provided app differs from another app with the same version and product id" for the Import-Part in the Updateing solution because the app is already installed. Can you assist here?

October 6, 2016 9:40 AM

Leave a Comment


About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems