DEV Community

CloudStakes Technology
CloudStakes Technology

Posted on • Updated on

Automating the process of adding a Site Collection Administrator (SCA) in SharePoint Online with Power Automate

Site Collection Administrator (SCA) in SharePoint Online

What Is a SharePoint Site Collection Administrator?

A SharePoint Site Collection Administrator (SCA) is a user with elevated privileges who has the ability to manage a specific site collection within SharePoint. The site collection is essentially a group of sites that share common features and settings and are managed as a single entity.

The SCA has a wide range of responsibilities and can perform various administrative tasks such as creating and managing sites, lists, libraries, and content types, as well as setting up user permissions and managing workflows. Additionally, the SCA can also configure and customize the site collection to suit the needs of the organization or project.

The role of the SCA is critical to the success of a SharePoint site collection as they are responsible for ensuring that the site is maintained and secure and that users have access to the necessary resources and tools to perform their tasks efficiently. They work closely with other administrators, such as SharePoint Farm Administrators and Site Owners, to ensure that the site collection is functioning optimally and meets the needs of the organization.

How does a SharePoint Site Collection Administrator (SCA) differs from a SharePoint site owner?

While both the SharePoint Site Collection Administrator (SCA) and Site Owner roles involve the management and administration of SharePoint sites, there are some key differences between the two roles.

The SCA is responsible for managing the entire site collection, which can consist of multiple subsites, libraries, lists, and other components. They have full control over the site collection settings and can perform administrative tasks such as setting up quotas and configuring site features. The SCA can also delegate certain administrative tasks to Site Owners but retains overall control and responsibility for the site collection.

On the other hand, the Site Owner role is responsible for managing a specific site within the site collection. They have the ability to manage site-level settings such as permissions, navigation, and content. Site Owners can also create subsites and manage lists and libraries within their site. However, they do not have the same level of control over the overall site collection as the SCA.

Adding a Site Collection Administrator (SCA)

To streamline the process of creating new SharePoint sites, it is possible to use Power Automate, a workflow automation tool, along with the SharePoint REST API to add a site collection administrator (SCA) to a new or existing SharePoint modern site.

To achieve this, we will utilize the Send an HTTP Request to SharePoint action available within Power Automate, which enables the integration of the SharePoint REST API. This will enable us to easily assign site collection administrator permissions to a user.

To add a site collection administrator (SCA) to a SharePoint Online modern site using Power Automate flow, follow the steps outlined below:

  • Access make.powerautomate.com and initiate the creation of a new Instant Cloud Flow by selecting the Manually Trigger a Flow trigger option.

  • Initially, it is necessary to add the user to the site collection's hidden User Information List through the use of the EnsureUser method within the SharePoint REST API. This method verifies the validity of the specified user within the site collection, and if the user is not present within the site collection, it adds them accordingly. To perform this operation, include the Send an HTTP Request to SharePoint action in the Power Automate flow.

  • The configuration settings for the Send an HTTP Request to SharePoint action should be arranged in the following format:

Method: POST
Uri: _api/web/ensureuser
Headers:

{
"content-type": "application/json;odata=verbose",
"accept": "application/json;odata=verbose"
}

Body:

{
'logonName': 'test@contoso.com'
}

  • Subsequently, it is necessary to obtain the SharePoint user ID from the User Information List to grant the specified user site collection administrator permissions. To accomplish this, include a Compose action in the Power Automate flow, and utilize the outputs generated by the EnsureUser method, as used in the preceding step. To retrieve the user ID, use the following expression within the Inputs of the Compose action:

@{body('HTTP_-_EnsureUser')?['d']?['Id']}

  • The final action involves updating the IsSiteAdmin property of the SharePoint user profile to "true," thereby adding the user as a site collection administrator. To accomplish this, include an additional Send an HTTP Request to SharePoint action in the Power Automate flow and configure it using the following format:

Method: POST

Uri: _api/web/getuserbyid(@{outputs('Compose-_User_ID')})

Headers:

{
"content-type": "application/json;odata=verbose",
"accept": "application/json;odata=verbose",
"X-HTTP-Method": "MERGE"
}

Body:

{
'__metadata': {
'type': 'SP.User'
},
'IsSiteAdmin': true
}

  • Once the necessary configurations have been made, it is recommended to save the Power Automate flow and then initiate a test run of the flow. This can be achieved by selecting the Test > Manually options located at the top right corner of the page. If the flow run completes successfully, the specified user will be added as a Site Collection Administrator (SCA) to the designated SharePoint Online site, thereby enabling them to perform administrative tasks for the site.

Final Thoughts

Automating the process of adding a Site Collection Administrator in SharePoint Online using Power Automate is a game-changer for SharePoint development services. By following the steps outlined in this article, you can streamline SCA assignment, save time, and reduce the risk of human error. This automated process ensures that the designated user receives the necessary permissions to manage the entire SharePoint site collection effortlessly. Embrace the power of automation to enhance SharePoint administration and unlock new levels of efficiency in your organization's collaboration and content management endeavors.

Top comments (3)

Collapse
 
jaloplo profile image
Jaime López

Thanks for the detailed explanation.

Collapse
 
lestinag profile image
Gregg

This works great for adding a person. Is it also possible to add a SharePoint group?

Collapse
 
pr0xtwit profile image
Jeff Santos

It works for groups.