Showing posts with label SharePoint CSOM Scripts. Show all posts
Showing posts with label SharePoint CSOM Scripts. Show all posts

Sunday, August 25, 2024

Top 3 Popular SharePoint CSOM (Client-Side Object Model) Scripts

The following are three popular SharePoint CSOM (Client-Side Object Model) scripts that can help manage and automate tasks:

  1. Using Multi factor Authentication 

This script allows you to connect to a SharePoint Online site using a Multi-Factor Authentication (MFA) account. It’s useful for securely accessing a SharePoint environment.


# Install SharePoint Online Client SDK

Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force -AllowClobber


# Connect to SharePoint Online

Connect-SPOService -Url https://yourtenant-admin.sharepoint.com


2. Provision SharePoint Sites

This script helps one set up sites with predefined configurations.


# Install PnP PowerShell

Install-Module -Name SharePointPnPPowerShellOnline -Force -AllowClobber


# Connect to SharePoint Online

Connect-PnPOnline -Url https://yourtenant.sharepoint.com -UseWebLogin


# Apply a provisioning template

Apply-PnPProvisioningTemplate -Path "template.xml"


3. Manage Permissions
This script helps when managing permissions for SharePoint Online sites, lists, and libraries. It can be utilized to grant or revoke permissions programmatically.


# Connect to SharePoint Online

Connect-PnPOnline -Url https://yourtenant.sharepoint.com -UseWebLogin


# Grant permissions

Set-PnPListItemPermission -List "Documents" -Identity 1 -User "user@domain.com" -AddRole "Contribute"