Exception calling “SaveAsTemplate” with SharePoint 2019

I was trying to use PowerShell with a modern site (Communication site in my case) to save a list/library as a template and getting this error:

Having the UnauthorizedAccessException can be little confusing, so what’s the catch?

To solve this, we’ll use PowerShell, code looks like this:

Microsoft introduced prevented custom scripts from running by default in SharePoint online, and now with the introduction of modern sites in SharePoint 2019, they’re prevented by default in modern sites in SharePoint 2019. With custom scripts feature enabled, saving the site as a template and saving lists/libs as a template won’t be possible, hence you get the UnauthorizedAccess error. When custom scripts is active, the DenyPermissionsMask propert of the site collection will be: “AddAndCustomizePages” .. in order to allow custom scripts, it has to be “EmptyMask”.

You’ll need to run this command:

$site.DenyPermissionsMask = [Microsoft.SharePoint.SPBasePermissions]::EmptyMask

Now you can save the list/lib as a template.

External Sharing Report In SharePoint Online

Hello readers! This is a short blog post to share with you a PowerShell script that would be helpful for Office 365 admins in order to know who shared content in SharePoint Online. This script will create a .csv file with a list for each site collection that has content shared outside of the organization, as well as the name of the person with access to your environment, his email, the date when he accessed your environment the first time as well as who invited him to your environment.

Here’s a link to the script on codeplex. Hope this helps someone out there when he’s asked to do a such a report!

PowerShell Error When Restoring Site Collection

SharePoint doesn’t allow the backup of a site collection and restore it in the same content database. If you backup a site collection and restore it, it will give you the following error.

So you need to make a new content database in the web application (in case the replication of the site collection at the same content database) so that the backed up site collection and the restored one are in different content database, but be careful to put the first database offline before you restore the new site collection.

 

Error occurred in deployment step ‘Recycle IIS Application Pool’: Cannot connect to the SharePoint site

One of the frustrating problems that you might face while developing SharePoint applications is some of the errors that you really don’t know how to troubleshoot, or where to start your investigation, one of the errors I had is the following:

Error occurred in deployment step ‘Recycle IIS Application Pool’: Cannot connect to the SharePoint site: << Site Collection URL >>. Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project.

For this error, my environment was 1 SharePoint development server connected to separate SQL server, I was assigned as the farm administrator, and the local administrator on the SharePoint server, but the problem is getting this error once you try to deploy using visual studio 2010, the solution here is that the user deploying using visual studio to have db_owner permission on the content database for the web application.

 

SP Unique Permissions Script

Hello Community,

I’ve seen many cases where a quick report would be needed to view broken permissions inside a SharePoint site. I even had this case for a customer who wanted to know if users broke some permissions in their own my sites, so I’ve made a script that will be scoped to a web application, and will loop through all site collections in that web application and tell you about any broken permissions for sites, lists or libraries, items or folders, and will give it to you in a .csv file with a nice formatting!  Click here to see how it would look in the .csv file

For more info, please visit: https://spuniquepermissions.codeplex.com/