How To Unpublish a Catalog in SharePoint 2013 Cross-Site Collection Publishing

Unpublishing a catalog in SharePoint 2013 either through the UI or in code is relatively simple. Doing it through the UI is as simple as the checkbox on the catalog settings page accessed from Library Settings -> Catalog Settings.

In code you can get this done with only one line of code in addition to any code it took you to get your hands on the SPList:

[Microsoft.SharePoint.Publishing.PublishingCatalogUtility]::UnPublishCatalog($list);

The interesting question is: What does it actually mean to do that?

All it means is that the list will no longer be picked up through search and presented as an available catalog to connect to! It does not actually disconnect preexisting connections. It will however no longer show the catalog as already connected to by a given web on the AddCatalogSource.aspx page accessed through Site Settings -> Manage Catalog Connections -> Connect to a catalog. In the page previous to that it will still show up and the few post connection editable settings will still be editable for the existing connection.

Also, deactivating the entire Cross-Site Collection Publishing feature for a site collection does not directly disconnect any consumers nor unpublish any catalogs. The UI for catalog settings will just not be accessible. Not that I am advocating taking such actions as "deactivate the XSP feature while a list is still nominated" for some reason. I'm merely presenting the currently tangible ramifications of either unpublishing a catalog or deactivating the XSP feature.