Retrieving the URL of an app catalog site in SharePoint 2013

In some of my recent work with the xSharePoint resources we came up with a need to retrieve the current URL of an app catalog so that we could determine if the current settings were correct or not. The issue with this is that we found there is no out of the box cmdlet to retrieve the current app catalog URL for a specific web application, only to update the settings with Update-SPAppCatalogConfiguration. To facilitate getting the current URL we had to do a bit of digging to find where it was stored after this point, and as it turned out this was found in the properties of the app feature which is turned on within the web application object. In order to retrieve the current URL we wrote the following little script to get it:

 $WebAppUrl = "http://sharepoint1:1234"

$wa = Get-SPWebApplication $WebAppUrl
$feature = $wa.Features[[Guid]::Parse("f8bea737-255e-4758-ab82-e34bb46f5828")]
$site = Get-SPSite $feature.Properties["__AppCatSiteId"].Value

return $site.Url

There are two things to notice here:

  1. The GUID we use here is a constant, it's the ID of the feature that is responsible for flagging the app catalogs presence in a web application
  2. The property that stores the GUID of the site collection is called "__AppCatSiteId"

This allows us to retrieve the site collection and get the URL that is currently used. Remember if you want to update this that you should use the Update-SPAppCatalogConfiguration cmdlet I mentioned before as manually manipulating this feature and its properties will get you in an unsupported state pretty quickly - but you can interrogate the values that SharePoint puts here to find the current app catalog URL if you need to read it for something you are working on.

Comments (0)

Skip to main content