I'm attempting to automate deployment of SharePoint Apps (Add-ins) to specific sites (Not adding to the app catalog) for an on-premises installation of SharePoint 2016. The user I am running this under is in the farm administrators group and I am able to upload the app to the app catalog and add it to the target site manually. To do this I am using the following powershell:

 "Importing $fullPath to $SiteCollection"
 $spapp = Import-SPAppPackage -Path "$fullPath" -Site "$SiteCollection" -Source ObjectModel -Confirm:$false
 "Installing $spapp" 
 $app = Install-SPapp -Web "$Web" -Identity $spapp  -Confirm:$false

$fullPath is a valid path to the .app file, $SiteCollection points to the site collection that I want to install this on and web is actually the same as site collection in this case.

I am getting the below error:

Import-SPAppPackage : Cannot open database "{Database Name}" requested by the login. The login failed. Login failed for user '{DOMAIN\user}'.

The user indicated in the error message is the same user who can add it to the catalog manually.

My question is actually two-fold:

First, any clues on that error and/or what further permissions I should ask the DBA for (Also a justification would be super helpful)

Second: I am doing this to automate deployments through TFS, is there a better way to do it? There is a TFS SharePoint deployment release activity, but that requires that the app be published to the catalog and we are trying to enable point-solutions to a specific site/web.

  • on which database it is complaining?
    – Waqas Sarwar MVP
    Commented Apr 21, 2017 at 15:37
  • The content database in which the site collection resides. thanks for asking, I should have included that. Commented Apr 21, 2017 at 15:40
  • Two things, are u login with the farm admin account on the server where power shell is running? And did you try to run as administrator to power shell window?
    – Waqas Sarwar MVP
    Commented Apr 21, 2017 at 15:41
  • Try to grant farm admin as DB owner rights on the said db
    – Waqas Sarwar MVP
    Commented Apr 21, 2017 at 15:42
  • While this specific case is for our dev/integration farm, the point of this is to eventually to do this in production and I don't think the DBAs are going to allow any permissions outside of what is prescribed for SharePoint farm admins. Is DB owner right standard for Farm Admins and the setup just missed it? Commented Apr 21, 2017 at 15:47

1 Answer 1


the error message is telling me that it is permission issue. Couple of things to check

  • Make Sure the account (under which u login) should have SPDataAccess membership role on the content Database.
  • ALso run the SharePoint powershell as Administrators.

Note: if your farm admin account is also as a setup account than this account need db_owner fixed database role for all databases in the server farm. Read more here: Plan for administrative and service accounts in SharePoint 2013

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.